topleft
topright

PureMVC on Google

PureMVC Blog-o-Sphere

Supporters

Linked-In Group

PureMVC on LinkedIn
 
Image
 
Is it ok to call Proxy methods from a Mediator? Print E-mail
Monday, 30 June 2008

QUESTION: 

From 'PureMVC Argument' by Jonathan Rowny

 

So me and the other people in my team got in a small argument over the proper use of PureMVC's mediators. We've read in various blogs that it is not a good practice to call a Proxy directly from a mediator. If you're going to call a proxy, it needs to be done from a command.

In this particular case, we're asking for the proxy to refresh some data. That's it... one call. someProxy.refresh(). The refresh will send it's notification and our mediator will update. So one of my coworkers wanted to register a command that called someProxy.refresh() and then send a notification from the mediator. If there was some business logic that needed to happen, I'd be all for it! But there isn't, we're just refreshing an array collection. So someone please tell me why should I register a command to call a proxy in this case?

 

ANSWER:

From "Best Practices and Implmentation Idioms ":

Coupling of Mediators to Proxies and other Mediators

Since the View is ultimately charged with representing the data model in a graphical, interactive way, a relatively tight one-way coupling to the application’s Proxies is to be expected. The View must know about the Model, but the Model has no need to know any aspect of the View.

Mediators may freely retrieve Proxies from the Model, and read or manipulate the Data Object via any API exposed by the Proxy. However, doing the work in a Command will loosen the coupling between the View and the Model.

 

Jonathan's complaint is justified. In this case, it is increased complexity and not called for. The relationship between the Mediator and Proxy is established and accepted within the framework best practices. The real benefit of the Mediator is that it decouples the View Components from knowledge of the Model and visa versa, which is where spaghetti code begins.

 

The need to decouple Mediators from Proxies is minimal, but the need to keep business logic in Commands is more defensible.

 

If there are more than 2 lines of code involved and those same lines need to be executed by multiple Mediators, then pushing those two lines into a Command and replacing them with a single line to send the Notification *might* be justified if it reduces the number of actors that the various Mediators need to know by placing the collaboration responsibility on a single Command. If those 2 lines ever need to change, at least it's in one place.

 

However, other requirements pressures in your app, such as the extra cycles to do the Notification processing and instantiate the Command can effect such a decision in certain problem domains such as 3D, Gaming, Audio, Video or Image processing.

 

-=Cliff>

Delicious
Technorati
Reddit
Furl it!
NewsVine
YahooMyWeb
Stumble
blogmarks
Digg
co.mments
connotea
 

PureMVC on the Web

Recently, Omar Gonzales at Almer/Blank developed and released ZamfBrowser; a ZendAMF service browser.  The AIR application was built using PureMVC Standard. for ActionScript 3 and the source code has kindly been made available online at the project's dedicated website

 

• ZamfBrowser Source Code Repository | Docs and Download

Almer/Blank Labs

 

 
The guys over at Pyjamas (a Python port of GWT) have made their compiler so efficient that it can take virtually any Python library and it will compile to Javascript. They loved the look of PureMVC Python, and decided to do a couple of demos that use it.
 

Pyjamas Project

• EmployeeAdmin Demo: Original / Pyjamas  

Pyjamas PureMVC Timesheet Demo

 
Chandima Cumaranatunge, co-author of the O'Rielly book AS3 Design Patterns, and long-time PureMVC community member recently created a simple Flash/AS3 MultiCore demonstration application accompanied by an informative article that's an excellent introduction to the benefits of working with MultiCore.
 
Who Moved the Cheese? - Demo / Source / Article

ActionScript 3 Design Patterns

 
FlashDevelop has gained quite a bit of ground in the development community so naturally several folks have created templates to ease the burdon of creating implementation classes. We'll let you be the judge of which are the best.
 
FDT PureMVC Templates, Well Formed and Pimped - Aron Woost
PureMVC First Thoughts and FlashDevelop Templates - Dave Keen

FDT Templates for PureMVC/AS3 Available - Pedr Browne

 

Ahmed Nuaman has published a well conceived and received AS3/PureMVC tutorial at FlashTuts.com. It's a good place for the learner to get their feet wet, and goes into the difference between using PureMVC with Flex as opposed to Flash or pure AS3.

 

Understanding the PureMVC Open Source Framework

FlashTuts Website
Ahmed's Website

 

 

Recent Project Activity

The PureMVC Java MulitCore GWT EmployeeAdmin Demo has been updated, now using Google Web Toolkit 2.0.

 

View the Demo

GWT EmployeeAdmin Project

 

The AS3 Undo Utility adds the ability to undo/redo actions in your PureMVC based Flex, Flash or AIR applications. The latest version is ready for download, and be sure to check out the demo to see how to implement.

 

AS3 Undo Utility

Flex HistoryPanel Demo

 

The PureMVC AS3 StartupManager Utility and its associated demos have been significantly refactored and improved. And to dispel the notion that the utility is only useful at startup time, it has been renamed Loadup

 

Loadup Utility 2.0

Loadup as Ordered Demo

Loadup for Assets Demo

 

The PureMVC / Objective C 1.1  has been released to keep up with the iPhone 3.0 SDK ( where 'dot notation' no longer seems to work ). 

 

PureMVC Framework for Objective C

Objective C Unit Tests

Employee Admin Demo


 

The Java MultiCore release 1.0.6 is available along with matching unit tests, utility and demos!

 

MultiCore Port & Unit Tests

Pipes Utility & Unit Tests

AsyncCommand

Employee Admin GWT Demo

 

 
Copyright © 2006-2008 Futurescale, Inc.