开发者

Implement a finite state automaton in OOP

开发者 https://www.devze.com 2023-01-03 20:51 出处:网络
I am thinking about implementing a program with finite state automaton in an OOP language like Java or C++.

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!


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)


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号