Question

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!

Was it helpful?

Solution

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)

OTHER TIPS

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

The dk.brics.automaton library is good implementation of FSA's in Java. It's build with performance in mind, so it trades in some OOP principles for speed, but i'd recommend you take a look at it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top