There are certainly other methods to achieve the same effect, but this
MVC approach fits best with frameworks like cairngorm, which already
leverage MVC to great extend. Why would we want to introduce another
mechanism? This just complicates things.

> To me, "state" is something only View's care about, and thus I'd prefer to
> keep those details out of the ModelLocator

State clearly belongs to the model. It's just that Flex blurs this
line a little bit, because views are never destroyed, so they can have
a state on their own.

As for enhancements to your code:
You could make it typesafe by creating a class for your state
variable. Also the constants should go into this class, and not into
the model locator.

Cheers,
Ralf.



On 7/17/06, JesterXL <[EMAIL PROTECTED]> wrote:
> 'cause ya' gotta keep track of 'em.  I'd much rather have state encapsulated
> away, and it just magically "knows" when to change.
>
> One way in Flex 2 is to:
> - put a set of state variables on ModelLocator like the below
> - bind your View's currentState to the ModelLocator's
> currentSometingRelevantState
> - build your View to implement some or all of those states.  (ex. User
> signed in, user auth failed, data retrieved, loading, etc.)
> - when the binded state changes, so does your View
> - dispatch events via Cairngorm's event dispatcher, and have your Commands
> change the current state on the ModelLocator
> - your view's will update
>
> I don't want to code things like the above because of the whole "having
> commands change the state", but I'd do it if you put a gun to my head.
>
> There are various other ways to, like using the binding tag in your View to
> bind to things that aren't necessarely state related on the ModelLocator,
> but DO affect your View's state.  You can bind to setters for example, and
> since setters are basically functions, you can run all kinds of magic beyond
> the simple currentState = "some different state".
>
> To me, "state" is something only View's care about, and thus I'd prefer to
> keep those details out of the ModelLocator, and allow the View's to handle
> the changes themselves like described above.  That could change tomorrow,
> though.
>
>
> ----- Original Message -----
> From: "ben.clinkinbeard" <[EMAIL PROTECTED]>
> To: <flexcoders@yahoogroups.com>
> Sent: Monday, July 17, 2006 3:27 PM
> Subject: [flexcoders] State vars: good, bad, ugly?
>
>
> As I perused the great sample app Jesse put together
> (http://www.jessewarden.com/archives/2006/07/flex_2_webservice.html),
> I came across his simultaneous implementation and criticism of state
> vars inside ModelLocator.
>
> // only do this if you have a 4 hour deadline;
> // some people think state vars are good.  I think
> // they are evil... but man, they sure work in a pinch.
> public static const STATE_READY:String = "ready";
> public static const STATE_SEARCHING:String = "searching";
> public static const STATE_DONE:String = "done";
>
> I need to implement something similar in my app as basically the whole
> thing resides inside a TabNavigator. I would like a simple, reliable
> way to direct the app to change states/tabs and this seems like a
> decent approach. What are people's opinions on this approach? Have a
> better alternative? Jesse, can you expound on why you think they're evil?
>
> Thanks,
> Ben
>
>
>
>
>
>
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
> Yahoo! Groups Links
>
>
>
>
>
>
>
>


-- 
Ralf Bokelberg <[EMAIL PROTECTED]>
Flex & Flash Consultant based in Cologne/Germany


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Yahoo! Groups gets a make over. See the new email design.
http://us.click.yahoo.com/XISQkA/lOaOAA/yQLSAA/nhFolB/TM
--------------------------------------------------------------------~-> 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to