File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes OO, Patterns, UML and Refactoring and the fly likes Is a FSM a good fit? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Is a FSM a good fit?" Watch "Is a FSM a good fit?" New topic
Author

Is a FSM a good fit?

Spikey Michael
Greenhorn

Joined: May 03, 2007
Posts: 1
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

Joined: Jan 07, 1999
Posts: 6920
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?


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is a FSM a good fit?