This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is a FSM a good fit?

 
Spikey Michael
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi People

I am responsible for designing and implementing a recovery system around transactions. The transaction effectively has a finite state it can exist in ie Voided, Cancelled, Secured etc.

I am thinking that this state could/should be governed through a state machine. Scripts are ran that can throw events on the transaction (such as store recovery data) that would cause the transaction to alter state, or a user can click a button etc.

What do you think? I'm not sure I entirely understand the benefits that a FSM brings.

Cheers
Mike
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In general the benefits of an explicit finite state machine appear when the state transitions get complex. If you don't need logic to determine which state to go to next, then really what you have is just a state indicator rather than a state machine.

Can you explain a bit more about the transitions between states in your system?
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Frank Carver:
In general the benefits of an explicit finite state machine appear when the state transitions get complex.


And if your FSM is complex the program code can become rather tedious - one of the reasons why Robert C. Martin wrote the first incarnation of SMC to generate the FSM program code from a state transition table. Object mentor now has a Java version available. Look for SMC - Finite State Machine Compiler (Java) on the object mentor web site's Resources-Downloads page.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic