Workflow Design Dilemma - State Machine, yes or no

前端 未结 9 1904
清歌不尽
清歌不尽 2020-12-03 05:38

I\'m a beginner with WF, but I\'ve read a book and done a lot of googling. I want to write an inventory management service. The inventory is made up of individual items whic

9条回答
  •  遥遥无期
    2020-12-03 06:02

    Given Your additions (more than 3 states, not all transitions are allowed), I would do the following:

    1. Store each item's state in the item itself.
      This can be achieved very easily: Add a member to a class or a column to a table etc., as others already mentioned in their posts/comments.
    2. Use one state machine (this can be anything from an instance of a class to a table with legal transitions), that holds your business logic, that is, the allowed transitions between states and the knowledge about what additional actions to perform, when an item changes its state.

    All you need to do then is to transform Your items using the state machine, whenever an extern event occurs, that forces/implies just that.

提交回复
热议问题