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: Simple site loading 2 or more types of data  (Read 8589 times)
eco_bach
Courseware Beta
Sr. Member
***
Posts: 81


View Profile Email
« on: July 11, 2009, 07:18:05 »

hi
I have a simple site with a navigation bar, visual loader and I need to be able to load 2 types of data, flickr feed data (xml) and swfs.

I have a  data.xml file which contains the urls , either to the local swf content or the flickr api feeds.

Right now, I let the Proxy(model) check the URL to see what type of data is being loaded, and then creates the corresponding loader logic(URLLoader for XML or Loader for SWF's)as well as corresponding handlers.

So I have 2 different notifications the Proxy sends, depending on the type of data loaded.

If I need to load additional types of data(flv, jpg, etc) I would need to check for this in the Proxy, and create additional notifications for each new type of data.

Is this a 'best practice' or is there a better way?
ie I was thinking perhaps that some people would put the logic for determining the type of data to be loaded in the Commands
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: July 11, 2009, 07:58:21 »

You should have a different proxy for each type of data. Sounds like 3 kinds of data: xml config, flickr feed data and swfs. So you'd probably have a ConfigProxy, a FlickrProxy and a SWFProxy.

Upon receiving the XML, you'd probably send a note that would be parsed by a Command which would in turn tell invoke loading methods on the other two Proxies.

-=Cliff>
Logged
eco_bach
Courseware Beta
Sr. Member
***
Posts: 81


View Profile Email
« Reply #2 on: July 11, 2009, 08:55:17 »

Ok thanks Cliff, will try refactoring according to your suggestions.


Right now I only map notifications to commands when I'm updating the proxy-model.

Not sure why you need to use commands when the information flow is FROM the proxies to the mediators, aren't the notifications sufficient?
Just trying to avoid any unneeded complexity...
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 on: July 11, 2009, 09:22:52 »

The idea is to keep the logic out of the mediators. You don't want to retrieve the configuration and then have the mediators interpret it and decide what to load.

-=Cliff>
Logged
eco_bach
Courseware Beta
Sr. Member
***
Posts: 81


View Profile Email
« Reply #4 on: July 11, 2009, 01:46:14 »

Hi Cliff
I realize what you are recommending is a best practice, but, for someone who is new to PureMVC, I feel the simpler approach( encompassing the logic for different datatypes) into one proxy makes sense until I am thoroughly comfortable with the framework.

Just a suggestion, perhaps there should be recommedned practices for beginners vs more experienced users?
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #5 on: July 13, 2009, 08:04:16 »

Best practices are best practices, whether you're a beginner or not. Understanding them is particularly important for a beginner, since you are learning your habits now.

While it is absolutely true that we sometimes 'don't learn till we get burned', best practices are the accumulated knowledge of those who've been burned before. By that token, you couldn't expect a parent to tell their children to go ahead and touch the hot stove top, knowing that they'll learn and not do it again later. The parent, understanding about burns, will always advise against touching hot things, regardless of the child's level of experience with them.

-=Cliff>
Logged
Pages: [1]
Print