Search code examples
oopsoftware-designautomaton

Implement a finite state automaton in OOP


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!


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)