您什么时候更喜欢使用状态机而不是线性工作流程
当存在多个循环和分支或逻辑时,当工作流必须对用户提供的答案做出“反应”时,状态机可以降低工作流的复杂性。这将是一个事件驱动的工作流程。
在什么情况下您选择使用状态机以及在时间和复杂性方面减少了哪些类型的痛苦?
State machines can reduce complexity of workflows when there are multiple loops and branching or logic when the workflow must "react" to answers supplied by users. This would be an event-driven workflow.
In what circumstances have you elected to use a state machine and what type of pain did reduce in terms of time and complexity?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
状态机非常适合事件驱动的代码。如果您的代码被调用作为对某些事件的响应,则不能使用循环和分支。您必须使用状态机,将事件输入其中以更改状态,并让事件处理程序根据机器的当前状态做出反应。
State machines are really nice for event-driven code. You can't use loops and branches if your code is being invoked as a response to some event. You'll have to use a state machine instead, feed the events into it to change the state, and have the event handler react according to the machine's current state.
状态机工作流适用于工作流完成过程中没有预定义步骤的情况。查看此定义(来自 状态机工作流程Windows 工作流基础)
State machine workflows are meant to be used when there is no predefined steps through workflow completion. Take a look into this definition (from State Machine Workflows in Windows Workflow Foundation)
状态机和线性工作流程是完全不同的问题空间,在应用程序开发方面是不相关的。
建模的流程驱动该方法,您可以将状态机用于具有多个状态的流程,在这些状态中工作单元可以存在,并且在这些状态之间存在潜在的非线性进展。如果存在明显的线性流程,并且没有显着的回溯,则将使用线性工作流程(或顺序工作流程)。
State machine and linear workflow are sufficiently different problem spaces to be unrelated in terms of application development.
The process being modelled drives the approach, you use a state machine for a process that has a number of states in which the unit of work can exist and for which there is a potentially non-linear progression through the states. Where a clearly linear process exists, one for which there is no significant backtracking then a linear workflow (or sequential workflow) would be used.