tag:robotlegs.tenderapp.com,2009-10-18:/discussions/robotlegs-2/11221-models-and-commandsRobotlegs: Discussion 2014-07-11T08:09:16Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/333990482014-06-14T10:03:43Z2014-06-14T10:03:43ZModels and Commands<div><p>Hey,</p>
<blockquote>
<p>So I should "force" somehow the others to use my command for
changing the property, and prevent it changed directly from for
example a mediator or another command.</p>
</blockquote>
<p>Yeah, put your team mates in chains and punish them in any way
you see fit, if they even think of touching the model in a mediator
:P</p>
<p>You could make your model sealable. Look at how Swiftsuspenders
seals/unseals a mapping:</p>
<p><a href=
"https://github.com/robotlegs/swiftsuspenders/blob/master/src/org/swiftsuspenders/mapping/InjectionMapping.as#L256">
https://github.com/robotlegs/swiftsuspenders/blob/master/src/org/sw...</a><br>
<a href=
"https://github.com/robotlegs/swiftsuspenders/blob/master/src/org/swiftsuspenders/mapping/InjectionMapping.as#L298">
https://github.com/robotlegs/swiftsuspenders/blob/master/src/org/sw...</a></p>
<p>Use something similar in your model, which should implement an
interface. The command could seal the model after setting its
property using a sealKey, and unseal it, if/when needed, by using
that "top secret" sealKey. Make the model throw an error in the
setters of its properties, if a class tries to set its properties
while the model is sealed.</p>
<p>That's just an idea. I hope it helps a little bit. Maybe there
are other solutions as well. I'm thinking of guards, but I don' t
have enough time right now to think it through.</p>
<p>Ondina</p></div>Ondina D.F.