views:

102

answers:

2

I am thinking about implementing a program with finite state automaton in an OOP language like Java or C++.

What would you think is the best way to implement this with a manageable amount of available states, regarding to good software design?

Is it good to implement for each state an own class? If yes, how to do the bridge between two states?

Thanks for any comment!

+1  A: 

Is this just to flex your programming muscle, or for an actual project etc? In either case it depends on what you want the state machine for: - is it to manage tasks in some sort of workflow - is it to determine application flow state - is it for a business rules engine etc

In the case of a project, I would suggest that, depending on what your target use is, you look for libraries in that domain. Java for example has MANY MANY libraries for workflow/busines flows, as well as tons of rules engines (Drools comes to mind right of the bat, although it is a complex behemoth)

Java Drinker
At the moment is is more a quastion of interest...during my study we had automatons in theory (very thoroughly), at this time I didn't understand, what they could be good for. Now I'm thinking about writing a (not very big) web project, using those
poeschlorn
A: 

Try this - the section on design is good and it shows a use for a fsm http://www.ibm.com/developerworks/library/wa-finitemach1/

Another use I've seen is to implement managed objects for a computer service, with the transition "start" moving the object from the "down" to the "starting" state etc using an extennsion of the OMG managed object life-cycle