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: Is my approach somewhat correct?  (Read 7077 times)
hesten
Sr. Member
****
Posts: 52


View Profile Email
« on: June 29, 2009, 12:15:44 »

Hi All
I'm trying to get my head around PureMVC. I am doing it by refactoring a really simple app I've done. So I thought I would ask here if my initial approach is somewhat correct, or if I am misunderstanding certain concepts?

The app is a searchable gallery of products.

The product data is loaded from a server, and the images are also dynamically loaded.

The user can enter various criteria and the gallery is then updated to display only the products that fit the criteria.

The user can then click a product image to get more information on that product.

Thats it.

So I have 3 view components;
UserSelectionUI (containing various buttons, a combobox and a search field)
GalleryView
ProductDisplayView
(and maybe an AlertView for error messages)

These view components gets a Mediator each.

I have two proxies;
ProductProxy (which loads the xml and stores the product list)
ParamsProxy (for flashvars)

The ProductProxy is initiated from a StartUp Command, when the xml is loaded it is parsed into a list of ProductVO objects, which the proxy now stores. It then sends a notification that the data is ready.
I am in doubt as to where I should put the filtering function that find product matches based on user input. Should it be in a Command or in the Proxy, or even in the UserSelectionUIMediator?
Right now I’ve implemented the filtering function in a Command (SearchCommand). The notification for the search contains a SearchVO containing all the search settings (the properties the user has selected).

But this means that the view component (UserSelectionUI) needs to populate the SearchVO and pass that to the mediator who then ships it with a notification to the Command. That’s a lot of shared knowledge isn’t it?

The Command needs to compare the result list with the previous result list to prevent an unnecessary update of the view. Since Commands holds no state information I’m storing the previous result list in the ProductProxy, is that ok?

Are VO’s part of the model controller or view?

Hope this makes sense?

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



View Profile WWW Email
« Reply #1 on: June 29, 2009, 05:13:06 »

This makes sense so far.

As for the shared knowledge, that's what the Value Object pattern is for; shuttling data across tiers of an app. The entire app has a single purpose: to allow the user to interact with the data model in various ways. Therefore the entities of that model must be agreed upon by all actors and so we create these 'data carrier' objects.

And to answer your last question, VOs belong to the model tier, and in PureMVC apps are usually found in the model/vo package.

-=Cliff>
Logged
hesten
Sr. Member
****
Posts: 52


View Profile Email
« Reply #2 on: June 29, 2009, 06:21:10 »

Thank you very much :)
Logged
Pages: [1]
Print