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: Where to store 'current language'?  (Read 7659 times)
eugene_se
Newbie
*
Posts: 5


View Profile Email
« on: January 05, 2009, 04:04:21 »

Hi,

I'm busy with my first PureMVC application and I have difficulties with modeling my data. I'm modifying the Login example using WebOrb to get started. In that example, an ApplicationProxy is used that stores the current state of the application in a local variable. It provides get/set functions to access the state.

1. Is it a good idea to use the ApplicationProxy to store the current language (English, German etc.) as well? Or is it wise to have a LanguageProxy that holds all possible languages and keeps track of the current language?

2. Furthermore, I don't fully understand the data object in proxies. Why can't you use public variables (or getter and setter functions) in proxies?

Thanks.  Hope someone can help me with these basic questions.

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



View Profile WWW Email
« Reply #1 on: January 05, 2009, 06:50:18 »

Hi Eugene,

First, if you want to create a LanguageProxy that sounds fine. It could also be an enum that is just a property of a larger set of configuration. See the EmployeeAdmin demo for the use of enums.

As for the public properties / accessors on proxies, there's no problem with that, though the proxy shouldn't itself become a bag for a ton of different props. That leads to the urge to bind to it (in flex) or otherwise make it available to view components. Rather the proxy should ideally be on charge of a VO which could be passed across tiers without making couplings to system actors.

The data property that exists in a Proxy is similar to the viewComponent property of the Mediator. It should hold an object or collection that the proxy tends, and that should be the extent of the data held by the Proxy. You should usually write a typed getter that returns that data object cast to the proper type. For instance the LanguageProxy might return a LanguageEnum.

It might just as easily be the case that you have a PrefsProxy that returns a PrefsVO that has a LanguageEnum as its language property. This might be preferable since you'll likely have other preferences info that may be used in the same places in the app that language is, and thus would reduce the number of proxies that have to be retrieved to apply the preferences to the view.

-=Cliff>
Logged
eugene_se
Newbie
*
Posts: 5


View Profile Email
« Reply #2 on: January 05, 2009, 10:53:52 »

Hi Cliff,

Thanks for your response. That really helps me understanding the framework. Amazing that you have time to develop the framework and also be so active on the forum.

Eugene
Logged
Pages: [1]
Print