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: State names question  (Read 4107 times)
letapjar
Newbie
*
Posts: 5


View Profile Email
« on: February 01, 2011, 05:02:45 »

In the finite sate machine tutorials/documentation it is suggested that gerunds are the best naming conventions for states and verbs (past tense) for transitions.

I am confused on how to appropriately name states such as when an application just starts up.  My application involves connecting to a social network to authenticate and get info about the social graph etc. 

so when we start up - the user is "Not Logged in"  or LOGGED_OUT - and when they authenticate with the social network they will become LOGGED_IN.

Is there a better way to name these states to conform to the gerund convention?
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: February 02, 2011, 09:01:38 »

That's a participle ('-ed' word) you're using, and just as valid for a  'static' state name.  (see http://puremvc.tv/#P003/T395 for more State Naming advice).

The key is to pick a worldview for conceiving your states from the outset and stick to it.

Static States
If you think of a state as a 'room' you enter in then you have a static worldview and will use participles to name your states.

Dynamic States
If you think of a state not as the room but as what you do in that room, then you have a dynamic worldview and will use gerunds (-ing words) to name your states.

A user is sitting at the login screen. Describe the state.

LOGGED_OUT - Static
In the static worldview, your user is LOGGED_OUT until they fill the login form and click submit. That may take them to a CREDS_SUBMITTED state where the server checks your credentials. If that fails, then you transition back to LOGGED_OUT, and a good return would take you to LOGGED_IN.

Note also that the use of participles tends describe things that have happened in the past. Not what is happening now, which is a little less appropriate. You're LOGGED_IN, but now what. What are your options? The state name doesn't give you a clue about what's going on now in the user's world.

LOGGING_IN - Dynamic

With a dynamic worldview you could say a user who is looking at a login screen is logging in. That is, they are looking at a form that collects their creds and they may be interacting with it at this moment. Clicking the submit button might take them to the AUTHENTICATING state where an animation plays while the server interaction happens. A bad return of service would transition us back to the LOGGING_IN state. A good return might take us to the SHOPPING state. Clicking the cart button would take us to CHECKING_OUT, and so forth.

So the use of gerunds for state names is much more focused on what the user or the system is doing right now.

Cheers,
-=Cliff>
Logged
letapjar
Newbie
*
Posts: 5


View Profile Email
« Reply #2 on: February 02, 2011, 12:52:19 »

Thanks Cliff,

In my head it was - user starts-out LOGGED_OUT - and when they succesfully authenticate then they are IDLING (one of several states while they are actually using the application) - when they logout - they are once again LOGGED_OUT  this is where the participle/gerund confusion was arising - I got the dynamic states for while the app wa running - but then could not think of a dynamic state for the non-authenticated state.
Logged
Pages: [1]
Print