Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Proxy related logic in the command  (Read 7561 times)
eliatlas
Jr. Member
**
Posts: 19


View Profile Email
« 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.



Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 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>

Logged
eliatlas
Jr. Member
**
Posts: 19


View Profile Email
« Reply #2 on: January 03, 2012, 09:09:40 »

Thanks Cliff!
Logged
Pages: [1]
Print