Factory pattern / constants
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?
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
Support Staff 1 Posted by Ondina D.F. on Jul 18, 2012 @ 09:04 AM
Hi lex,
There are a few approaches I’m aware of:
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 :)
Ondina
2 Posted by lex on Jul 18, 2012 @ 03:51 PM
Sweet — I will inject, then, pass GO and collect my $200!
Support Staff 3 Posted by Ondina D.F. on Jul 19, 2012 @ 07:27 AM
Cool!
Ondina D.F. closed this discussion on Jul 19, 2012 @ 07:27 AM.