What is the difference between a state machine and the implementation of the state pattern?

前端 未结 6 1080
無奈伤痛
無奈伤痛 2020-12-24 05:41

I wonder if a state machine is just the state pattern at work or if there is actually a difference between those two?

I found this article with the

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-24 06:30

    A state machine can be designed and implemented in several ways. One way is to use the state pattern described in the book by the Gang of Four. But there are other patterns to implement a state machine.

    For example, you may want to have a look at the research of Miro Samek by reading the book Practical UML statecharts in C/C++, 2nd ed. (Event-Driven Programming for Embedded Systems)

    You may also find interesting this question.

提交回复
热议问题