Settings and Game State Manager - best practice

anshumang001's Avatar


30 Jun, 2014 09:28 PM

I am writing an application in which current language of OS needs to be detected, and based on that preference , desired actions are taken by some commands and views.So to access the current language preference , there must be a global application state which can be accessed by commands and views.What is the best practice for implementing such a case?
This is one of the examples, another example may be a setting for turning sound on/off, detecting the current aspect ratio of mobile, etc. How to maintain and use these global settings or states?. I thought of models as solution , as they are usually singleton and ideally used for game states but best practice suggest that model should not be injected directly into mediator and view.Passing each and every setting , whenever required by the view, through an event is an overkill in my opinion.
Please suggest what should be the best practice for such a scenario?

  1. 1 Posted by greenLED on 01 Jul, 2014 03:11 AM

    greenLED's Avatar

    I have not worked with movile devices before, but I think that if you need
    to access some external resource, eg. to get the current language, you
    shoud do it through a Service with a Command, and store the value in a
    Model. Then, access the model from the mediator, never from the view
    because views are not injected (by default). Best practices say that
    mediators should not know about models and services because of the
    coupling, but they also say that you can access them from mediators
    through their interfaces without serious coupling risks.

    You can also have two or more global application states, one for each part
    (language, volume, etc.). Also, if aspect ratio or any other setting is a
    static variable aviable in the SDK, then you already have a "Singleton"
    which can be used also in views without injection or events.

    El Lun, 30 de Junio de 2014, 5:30 pm, anshumang001 escribió:

  2. Ondina D.F. closed this discussion on 01 Sep, 2014 12:32 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac