PureMVC Architects Lounge

PureMVC Manifold => MultiCore Version => Topic started by: aviddv1 on July 19, 2009, 01:03:12

Title: VIEW <-> PROXY
Post by: aviddv1 on July 19, 2009, 01:03:12
Hey there,

I'm new to PureMVC and thus far I'm loving it.  I love how organized it's forcing me to be.  I have a two-part question about views and proxies.  I completely understand the importance of keeping them decoupled, however (and maybe I'm just doing this all wrong), I find myself needing about 12 parameters from a proxy in order to set things like colors, width, an array of items, etc.  I understand I can have the mediator get all of these items and just pass them to the view, however wouldn't it just be more efficient if I can talk directly to the proxy from a view?  I've even tried breaking up my code so some of the dependency on data from the proxies is handled inside the mediator.

Bottom line is how can I pass a large number of parameters without creating parameter objects then parsing them within the views?

Part two of my question has to do with nested views.  If Im creating a view that is a menubar and within the view I have a number of links which are created dynamically from a link view, can I add the link view directly into the menubar view?  If I have to use a mediator wouldn't I have to add one for each instance of the link view?

If I'm able to add each instance of the link view directly to my menubar view I've got to think about a whole new set of parameters originating from the proxies that need to be passed through the menubar view to the link views so they can be configured.

Am I going about this all wrong?  My goal is:

Menubar View
  - Link View (instance 1)
  - Link View (instance 2)
  - Link View (instance 3)
  - etc.


Title: Re: VIEW <-> PROXY
Post by: Sammi on July 20, 2009, 04:11:25

I would just make a VO for these properties and have the mediator pass it to the view.  It may sound like a lot of extra work, but it really isn't.  And you get code completion for the properties.

I would just have a MenuBarMediator that manages both the MenuBarView and it's nested views.  I would actually also not have the links as 'views'.  They could be classes, but I would not think of them as views in PureMVC terms.  That would be too granular for my taste.


Title: Re: VIEW <-> PROXY
Post by: puremvc on July 21, 2009, 07:57:27
The Value Object pattern (VO) that Sammi mentioned is the right answer here. It is a simple class with all the props needed and you can pass that across from the Proxy to the Mediator in a note body. Or the Mediator can retrieve the Proxy and get the VO with a single call and set it on the view component with a single call.

Spoon-feed your components in this way, don't have them talking directly to Proxies or you'll be making the very coupling that MVC is intended to avoid.