Data and Injector Best Practice

Philip's Avatar

Philip

25 Nov, 2013 12:46 PM

Hi,
would it be considered bad practice to divide data and use the Injector in the following way:

a) inject all values that don't change, e.g values coming from a data.xml

b) create a model to hold those values that do change

  1. Support Staff 1 Posted by Ondina D.F. on 26 Nov, 2013 10:25 AM

    Ondina D.F.'s Avatar

    Hi Philip,

    a) inject all values that don't change, e.g values coming from a data.xml

    Of course it depends on the use case, but since you're asking just for a general rule, I'd say it is absolutely ok to inject immutable properties into the classes that need them for some kind of configuration - user credentials, layout..

    b) create a model to hold those values that do change

    Yes, that's the role of a Model, to hold and manipulate application's states
    http://knowledge.robotlegs.org/kb/reference-mvcs-implementation/wha...

    It is a good practice to inject Models against an interface.

    Ondina

  2. 2 Posted by Philip on 26 Nov, 2013 10:44 AM

    Philip's Avatar

    Hi Ondina,

    yes, I would find it quite practical to inject configuration data and then use models for application states, etc.

    Thanks,
    Philip

  3. Philip closed this discussion on 26 Nov, 2013 10:44 AM.

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

Keyboard shortcuts

Generic

? 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