tag:robotlegs.tenderapp.com,2009-10-18:/discussions/robotlegs-2/9916-needing-a-recap-model-andor-proxyRobotlegs: Discussion 2014-02-19T09:15:25Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/316696382014-02-18T12:29:15Z2014-02-18T12:29:15ZNeeding a Recap : Model and/or Proxy<div><p>Having worked with Robotlegs and Pure MVC I Sometimes still
ponder the question what the best use of Proxies is in
Robotlegs.</p>
<p>I understand Proxies to be classes that allow you to set values
of value objects or more often retrieve them. They are the
'mediators' of value objects.</p>
<p>In my practice I often however let classes that begin with the
name Service, set the values of any Value Object, and I use a Model
class (actor) to notify the framework of such Value Objects. My
flow can be</p>
<p>Command --> Calls Service, service loads data and populates
VO --> Command catches service updated VO and calls Model to
notify framework of updated VO and do any logistics.</p>
<p>So my Model acts like a Proxy? If using a Proxy class where in
the above flow would it come in. I guess the deeper question is
what is the difference between a Model and a Proxy. And Should the
model reference a Proxy?</p>
<p>Many thanks for any clarity or recommended best practice or "day
in the office and I Am having coffe and this is what I do!"
feedback.</p>
<p>Thanks in advance<br>
Thomas</p></div>thomas.thorstenssontag:robotlegs.tenderapp.com,2009-10-18:Comment/316696382014-02-18T14:16:33Z2014-02-18T14:16:33ZNeeding a Recap : Model and/or Proxy<div><p>Hi Thomas!</p>
<p>I'm drinking coffee while answering your questions;)</p>
<blockquote>
<p>I guess the deeper question is what is the difference between a
Model and a Proxy.</p>
</blockquote>
<p>PureMVC:<br>
<strong>Proxy</strong> code <strong>manipulates</strong> the data
model, <strong>communicating</strong> with remote services if need
be to persist or retrieve it. The Proxy may be used not only to
control access to data but also to perform operations on the data
as may be required to keep that data in a valid state.</p>
<p>Robotlegs MVCS has split the responsibilities of a pmvc Proxy
into 2 classes, Model and Services :</p>
<p><strong>Model</strong>: <strong>manipulates</strong> the data
and holds the <strong>state</strong> of the application</p>
<p>[<a href=
"https://github.com/robotlegs/robotlegs-framework/wiki/Best-Practices#model">https://github.com/robotlegs/robotlegs-framework/wiki/Best-Practice...</a>]
[<a href=
"https://github.com/robotlegs/robotlegs-framework/wiki/Best-Practices#models">https://github.com/robotlegs/robotlegs-framework/wiki/Best-Practice...</a>]</p>
<p><strong>Service</strong>: accesses external
<strong>resources</strong> (remote servers, file system..)</p>
<p><a href=
"https://github.com/robotlegs/robotlegs-framework/wiki/Best-Practices#services">
https://github.com/robotlegs/robotlegs-framework/wiki/Best-Practice...</a></p>
<p>In PureMVC, there is something called a SmartVO, which is kind
of similar to a robotlegs' Model, but not the same.<br>
<a href=
"http://forums.puremvc.org/index.php?topic=1293.msg5973#msg5973">http://forums.puremvc.org/index.php?topic=1293.msg5973#msg5973</a><br>
<a href=
"http://forums.puremvc.org/index.php?topic=1729.0">http://forums.puremvc.org/index.php?topic=1729.0</a></p>
<p>In PureMVC, there are variations on the Proxy pattern:</p>
<ul>
<li>
<p>Remote Proxy, where the data managed by the concrete Proxy is in
a remote location and will be accessed via a service of some
sort.</p>
</li>
<li>
<p>Proxy and Delegate, where access to a service object needs to be
shared between multiple Proxies. The Delegate class maintains the
service object and controls access to it, ensuring that responses
are properly routed to their requestors.</p>
</li>
<li>
<p>Protection Proxy, used when objects need to have different
access rights.</p>
</li>
<li>
<p>Virtual Proxy, which creates expensive objects on demand.</p>
</li>
<li>
<p>Smart Proxy, loads data object into memory on first access,
performs reference counting, allows locking of object to ensure no
other object can change it.</p>
</li>
</ul>
<blockquote>
<p>And Should the model reference a Proxy?</p>
</blockquote>
<p>Not if you use robotlegs MVCS, where a Proxy would be a Service
class. You can, however, inject Models (better as an interface)
into Services, if you need /want to.</p>
<p>But, Robotlegs MVCS != Ten Commandments.<br>
So, you're free to design your classes as you wish, like in using a
Proxy (Model+Service) à la PureMVC.<br>
Personally, I like having separate Models and Services, each with
its own distinct role/repsonsabilities/concerns.</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/316696382014-02-18T14:27:03Z2014-02-18T14:27:03ZNeeding a Recap : Model and/or Proxy<div><p>Ondina</p>
<p>Glad to hear that you had some coffe. Always good with a cup of
Java as we say.</p>
<p>This response is very clear and I now much better understand
what is the specifics of the MVCS idea in relation to Proxy and the
comparison to MVC was great. I Shall stick to my Model Services
approach in RL. But might further inspect the Proxy approach in
PureMVC.</p>
<p>Many Thanks</p>
<p>Thomas</p></div>thomas.thorstenssontag:robotlegs.tenderapp.com,2009-10-18:Comment/316696382014-02-19T09:15:25Z2014-02-19T09:15:25ZNeeding a Recap : Model and/or Proxy<div><p>You're welcome, as always!</p></div>Ondina D.F.