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: Q; State pattern to represent 'logged IN' and 'logged OUT' ??  (Read 6901 times)
eco_bach
Courseware Beta
Sr. Member
***
Posts: 81


View Profile Email
« on: August 31, 2009, 05:56:08 »

I've built an application that has a number of sequentially viewed steps (my view components) and also also allows the user to be either 'loggedIN' or  loggedOUT'  while navigating from step to step.

Chapter 10 of the excellent 'HeadFirst DesignPatterns' describes the State Pattern as 'encapsulating state-based behaviour and delegate behaviour to the current state'

I'm thinking that being 'logged IN' or 'logged OUT' represent 2 discreet states and perhaps I should be implementing the state pattern (ie the FinalStateMachine) BUT,  the behaviour of my application doesn't change on logged IN or OUT, only the appearance changes.

Can anyone share their rationale and or examples in using the State machine and-or help clarify the above?
« Last Edit: August 31, 2009, 06:02:24 by eco_bach » Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: August 31, 2009, 06:28:29 »

You might want to have a peek at the State Machine overview presentation here: http://puremvc.tv/#P003/

This will give you an idea of how to cope with application state. View state is a different matter. Each view component may have any number of states that do not directly correspond to overall application state. And sometimes it is a one to one relationship. The overview presentation describes how Mediators can listen to the StateMachine and keep their individual view states in sync with the overall application state.

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


View Profile Email
« Reply #2 on: August 31, 2009, 08:10:13 »

ok thanks Cliff.
As I understand it one of the goals of the FSM is to decouple view component state management (VISUAL) from overall application state (BEHAVIOURAL ) management using Mediator logic to determining what to change in the associated visual component.

A mediator could listen to a 'CHANGED' event to swap out a graphic or somehow change the component.

But I'm still not clear if it would make sense to describe each sequential step in my application as 'states'. My guess is NO, since as I understand it, states should describe global properties or conditions of the entire application. And the only 2 global conditions of my application are 'LOGGED IN' and 'LOGGED OUT'.

....just trying to figure out the best way to integrate FSM into my PureMVC project without complicating things


« Last Edit: August 31, 2009, 08:22:44 by eco_bach » Logged
Pages: [1]
Print