PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: eliatlas on January 03, 2012, 03:01:31



Title: Proxy related logic in the command
Post by: eliatlas on January 03, 2012, 03:01:31
Let's say I have a proxy, with some properties in it.
And I have a command that has to access the API of the proxy, depending on some logic related to the properties of the proxy.
Where should I have all the logic, inside the command, or inside the proxy?

For example:
:
if (myProxy.a > myProxy.b)
{
    myProxy.foo()
}
else
{
    myProxy.foo2()
}

or just
:
    //figureFoo compares myProxy.a and myProxy.b and calls the relevant function in myProxy
    myProxy.figureFoo()

The reason I am asking, is that the logic is pretty complicated, and I want the proxy to be clean.





Title: Re: Proxy related logic in the command
Post by: puremvc on January 03, 2012, 08:37:58
The Proxy, or a Value Object is probably the best place as opposed to a Command.

If you don't want the Proxy to have this logic, you could have a Value Object with properties a and b and the method figureFoo(), or better yet an implicit accessor get foo(), so that it appears you have a derived property foo (assuming you're using AS3, if not, then just a getFoo()).

The reasoning for not putting domain logic into a command (where business logic lives) is that it makes it difficult to reuse the Model tier - one of the most valuable outcomes of using MVC. For instance, my current client has a Flex web application that we now have a desktop viewer for, as well as an iPad viewer. The use cases and consequent business logic varies from app to app, but the Model tier remains the same.

-=Cliff>



Title: Re: Proxy related logic in the command
Post by: eliatlas on January 03, 2012, 09:09:40
Thanks Cliff!