tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/565-multiple-models-centralizing-of-static-constantsRobotlegs: Discussion 2013-04-28T10:20:52Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/74924362011-05-27T13:08:40Z2011-05-27T13:08:40ZMultiple Models : Centralizing of static constants<div><p>About the only thing I'd ever use public static consts for are
event<br>
types and similar stuff that can be relied upon not to be<br>
context-sensitive in any way whatsoever. Those you can just
reference<br>
directly without involving Robotlegs at all.</p>
<p>For everything else, I'd recommend using non-static values,
wrapped in<br>
some sort of VO which you can inject into as many models as you
like.<br>
If you only expose getters you can rely on the values not being<br>
tampered with, so they're as safe to use as consts.</p>
<p>cheers,<br>
till</p></div>Till Schneidereittag:robotlegs.tenderapp.com,2009-10-18:Comment/74924362011-05-27T13:26:27Z2011-05-27T13:26:27ZMultiple Models : Centralizing of static constants<div><p>I been following the discussion about immutable value objects
some. Time to go for it!</p>
<p>Yeah I see what you mean here and I will follow your fine
advice.</p>
<p>However, Injecting value objects but value objects are quite
plain so they should I assume still not extend any class ?</p>
<p>How should I map them? Might be silly question but...</p></div>thomas.thorstenssontag:robotlegs.tenderapp.com,2009-10-18:Comment/74924362011-05-27T13:31:52Z2011-05-27T13:31:52ZMultiple Models : Centralizing of static constants<div><p>Your VOs don't need to extend any specific class, no. To be able
to<br>
only expose their getters, you can implement an interface that
does<br>
just that and inject the VO as that interface:</p>
<p>var myConfigVO : MyConfigVO = //create and configure the vo<br>
injector.mapValue(IMyReadOnlyConfigVO, myConfigVO);</p>
<p>Obviously, your VOs' real names shouldn't be nearly as silly as
the<br>
ones I'm using here ...</p></div>Till Schneidereittag:robotlegs.tenderapp.com,2009-10-18:Comment/74924362011-05-27T13:39:08Z2011-05-27T13:39:08ZMultiple Models : Centralizing of static constants<div><p>Excellent, I will do some refactoring this weekend of a project
and implement this soultion!</p>
<p>Thanks. I'll be back</p>
<p>Thomas</p></div>thomas.thorstenssontag:robotlegs.tenderapp.com,2009-10-18:Comment/74924362011-05-27T13:41:05Z2011-05-27T13:41:05ZMultiple Models : Centralizing of static constants<div><p>Great, glad I could help!</p></div>Till Schneidereit