Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Welcome, Guest. Please login or register.
December 12, 2017, 08:25:34 PM
Home Help Search Login Register
News: Please DM @puremvc on Twitter to gain forum access. Spambots are why we can't have nice things.
Pages: [1]
Print
Author Topic: Mediator to View relationships and Webservice method to commands  (Read 3425 times)
albertkang75
Newbie
*
Posts: 7


View Profile Email
« on: September 09, 2009, 02:25:03 PM »

I am so far just reading and learning about puremvc and just wrote my first few lines in converting an app (very old AS 2 v2.0 components) to flex/puremvc.

so question 1:
is it best practice to have a 1:1 relationship btwn a mediator and a view?

question 2:
if i have a webservice with 3 methods, I should also have 3 Command classes?  i.e. webmethods to Commands are also 1:1?

Logged
albertkang75
Newbie
*
Posts: 7


View Profile Email
« Reply #1 on: September 09, 2009, 03:08:14 PM »

i would also like to clarify - by view i mean 1 component. (i.e a tree, tilelist, etc)
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW
« Reply #2 on: September 10, 2009, 06:34:33 AM »

There is to prescribed relationship between the number of view components and mediators. You'll learn about the right granularity as you go, and you can search for 'granularity' and mediators in this forum for a lot of discussion.

For a service, typically you'll have one proxy for the service but that's not hard and fast either. It all has to do with how the service is implemented.

Most service endpoints are designed to work with a particular data type and give you various functions against it like list, search, fetch, update, remove, etc. In this case a single proxy that deals with that data type becomes the single place in the app for keeping that data and causing updates to it.

However if a service works with a number of different data types, you might put the service information into a delegate class and have several proxies that use the same delegate to access the service.

The proxies are generally aligned around data type in the application, not around the service accessed to maintain the data. We don't want the rest of the application to even know there is a service, or to have code that is tied to a specific service. This keeps the whole client portable.

And commands are needed when coordinating an update between the model and view could not be done directly, or where there is a lot of duplication going on in the mediators where proxy communication is involved.

-=Cliff>
Logged
isragaytan
Full Member
***
Posts: 22


View Profile Email
« Reply #3 on: September 10, 2009, 08:02:02 AM »

Question 1:
is it best practice to have a 1:1 relationship btwn a mediator and a view?

A : Also remember that the mediator is the "best friend" of the view. So it definetively knows him. The mediator listens for all the events and custom events dispatched from your view to take proper actions.

question 2:
if i have a webservice with 3 methods, I should also have 3 Command classes?  i.e. webmethods to Commands are also 1:1?

Some guys go directly from the mediator to the proxy and consume all the methods exposed by the proxy. Then the proxy send notifications and the interested mediators take proper action to handle that notifications. I dont recomend that, i prefer put in commands for encapsulate business logic.
Logged
Pages: [1]
Print
Jump to: