tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/966-factory-pattern-constantsRobotlegs: Discussion 2012-07-19T07:27:26Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/173643042012-07-16T22:30:05Z2012-07-16T22:31:37ZFactory pattern / constants<div><p>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(...).</p>
<p>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.</p>
<p>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.</p>
<p>Maybe I'm going about this all wrong?</p></div>lextag:robotlegs.tenderapp.com,2009-10-18:Comment/173643042012-07-18T09:04:54Z2012-07-18T09:04:54ZFactory pattern / constants<div><p>Hi lex,</p>
<p>There are a few approaches I’m aware of:</p>
<ol>
<li>reference static constants directly in the view</li>
<li>model - event - mediator - pass payload(VO) to the view</li>
<li>inject the VO as an interface into mediators and pass it to the
view (use injector.mapValue)</li>
<li>fluent factory</li>
<li>Stray’s request provide pattern</li>
</ol>
<p>Obviously you are already aware of the factory method –
you mentioned it in your title.</p>
<p>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 :)</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/173643042012-07-18T15:51:12Z2012-07-18T15:51:12ZFactory pattern / constants<div><p>Sweet — I will inject, then, pass GO and collect my
$200!</p></div>lextag:robotlegs.tenderapp.com,2009-10-18:Comment/173643042012-07-19T07:27:25Z2012-07-19T07:27:25ZFactory pattern / constants<div><p>Cool!</p></div>Ondina D.F.