issues
search
hhstore
/
blog
My Tech Blog: about Mojo / Rust / Golang / Python / Kotlin / Flutter / VueJS / Blockchain etc.
https://github.com/hhstore/blog/issues
288
stars
24
forks
source link
FSM(Finite State Machines) vs PN(Petri Nets)
#144
Open
hhstore
opened
5 years ago
hhstore
commented
5 years ago
FSM(有限状态机) vs PN(Petri网)
https://stackoverflow.com/questions/53980748/whats-the-difference-of-petri-nets-and-finite-state-machines
https://en.wikibooks.org/wiki/Embedded_Control_Systems_Design/Finite_State_Machines_and_Petri_Nets
https://blog.csdn.net/cug_heshun2013/article/details/51244420
有限状态机FSM的原理与GO的实现
应用场景:
复杂状态流转, 切换, 回滚, 控制.
FSM 本是
编译器
设计中一部分. 业务开发中不多见.
常见场景
: OA, ERP, 电商订单, 审批流, workflow流, 各种交易系统.
使用
FSM
可以简化业务流程判断逻辑. 解耦业务, 不易出错, 且容易扩展, 应对需求变更.
hhstore
commented
5 years ago
FSM(有限状态机):
应用场景:
OA 单: 状态变更
ERP 物料: 管理/跟踪
电商 Order 订单: 状态变更(下单/待付款/付款/物流/退款/退货/取消订单/完成)
交易系统
项目:
go:
搜索:
https://github.com/topics/finite-state-machine?l=go
搜索:
https://github.com/topics/fsm?l=go
搜索:
https://github.com/topics/state-machine?l=go
qor 实现:
https://github.com/qor/transition
应用示例:
https://github.com/qor/qor-example/blob/master/models/orders/state_machine.go
https://github.com/looplab/fsm
https://github.com/smallnest/gofsm
Python:
https://github.com/topics/finite-state-machine?l=python
https://github.com/oxplot/fysom
示例代码:
一个电商项目 order 订单流:
https://github.com/qor/qor-example/blob/master/models/orders/state_machine.go
hhstore
commented
5 years ago
PN(Petri网):
比较复杂, 可参考 stackoverflow 回答, 解释了 PN 和 FSM 的区别.
大多场景, FSM 就够用. 实现也简单易懂.
hhstore
commented
5 years ago
-
FSM(有限状态机) vs PN(Petri网)
应用场景:
编译器
设计中一部分. 业务开发中不多见.常见场景
: OA, ERP, 电商订单, 审批流, workflow流, 各种交易系统.FSM
可以简化业务流程判断逻辑. 解耦业务, 不易出错, 且容易扩展, 应对需求变更.