Day 2 – Continuing to develop a prototype


I was working on a small prototype for a mobile game from a couple of weeks. Its decently done enough that i can show it off to people and get some feedback. Its kind of mix and match between hayday and a Clicker game. I will probably add snapshots in a couple of days.

Anyway, as i was coding, i had to appreciate a couple of patterns i follow which makes coding so much easier ( and re-usable ).

Event system: I raise/push an event with context from anywhere. And else where, if am listening to that particular event type, i would get notified along with the context. Context can be anything which is relevant to that particular event. In this case, am simply sending an Int, with the information of the modified currency.

Dependency Injection / Delegates: When you strictly follow the MVC architecture, you cannot put Logic in View classes. Logic strictly goes into Controller. So one of the patterns i frequently use is Dependency injection, where i will send the dependencies from the Controller classes to the View classes. This dependency can simply be a couple of lines of code which needs to be executed on a button press. The view class has no clue whats in the dependency, but it simply executes it when needed. Thus, the code was modular and independent of each other.

You can see it in the below example how am using multiple delegates and sending it to a view class “UiConnectionInformationPopup”. The view classes execute these delegates based on user actions.

Delegates: is certainly one thing i am a big fan of in C#. Unlike function pointers in C++ ( which is helpful but the syntax is messy ), delegates are super easy to use. There are predefined delegate already defined like System.Action and System.Func which come in super handy.

1 thought on “Day 2 – Continuing to develop a prototype”

  1. Erwin smith says:

    Go armin!!

Leave a Reply

Your email address will not be published. Required fields are marked *