PureMVC Architects Lounge

Announcements and General Discussion => Architecture => Topic started by: albertkang75 on September 12, 2009, 01:13:17



Title: Multiple State Machines?
Post by: albertkang75 on September 12, 2009, 01:13:17
Is it possible/advisable to have multiple state machines in an app?

For example, have a state machine for the entire app (i.e - startup as used in the sea of arrows) and then have another state machine that is used for some forms that appear in a popup window (i.e a sort of like the FSM as described in the puremvc.tv).

Or should I just use the state machine for startup related things and then have a separate mediator handle the form and it's various states?





Title: Re: Multiple State Machines?
Post by: puremvc on September 13, 2009, 06:58:04
Using MultiCore, each core can have its own StateMachine. So if your Popup were a module with its own PureMVC core, you could go that way. If the popup talks to a service that nothing else in the app talks to, it might make sense to modularize and place the form, its mediator, the proxy that communicates with the service into a core. This also makes the whole business maximally reusable.

But more than likely, a State Machine instance for a form is not what you're looking for. Flex has view states, which allow a component to have multiple visual configurations. It takes care of all the business of state transitions for you, even animating them if you'd like. That combined with binding that enables and disables things based on the form is really the best way to encapsulate your form's behavior within the component.

-=Cliff>