Factory pattern / constants

lex's Avatar


16 Jul, 2012 10:30 PM

I've read a few threads similar to my issue, but I'm still not clear on how to handle this within RL. I have a Class (I originally declared it as a VO, then changed it to a Model, then hit a wall) that contains properties of different TextFormats along with a StyleSheet. This class also contains a few 'factory-type' methods such as getTextField(...) and getHTMLTextField(...).

The TextFormat and StyleSheet properties will eventually be defined within a config XML file — those properties will then be stored into this Class. Most of my views will need access to this Object — to draw textFields within the views and utilize these somewhat Gobal font formatting properties.

What is the best way to handle this type of Object? It seems that injecting this into mediators is bad practice, But, if this Object is a VO, I don't really want to pass the VO through an event to distribute it's properties to mediators, then pass to the views. Only because there are possibly numerous occasions during runtime where a view will need to access this 'global' font properties, draw textFields etc.

Maybe I'm going about this all wrong?

  1. Support Staff 1 Posted by Ondina D.F. on 18 Jul, 2012 09:04 AM

    Ondina D.F.'s Avatar

    Hi lex,

    There are a few approaches I’m aware of:

    1. reference static constants directly in the view
    2. model - event - mediator - pass payload(VO) to the view
    3. inject the VO as an interface into mediators and pass it to the view (use injector.mapValue)
    4. fluent factory
    5. Stray’s request provide pattern

    Obviously you are already aware of the factory method – you mentioned it in your title.

    It sounds like your configuration “Object” won’t change after run time, thus you could inject it into your mediators as an interface, exposing only getters, without contravening the law of “do not inject models and services into mediators”. No penalty fees will be charged :)


  2. 2 Posted by lex on 18 Jul, 2012 03:51 PM

    lex's Avatar

    Sweet — I will inject, then, pass GO and collect my $200!

  3. Support Staff 3 Posted by Ondina D.F. on 19 Jul, 2012 07:27 AM

    Ondina D.F.'s Avatar


  4. Ondina D.F. closed this discussion on 19 Jul, 2012 07:27 AM.

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