What is the difference between sequential and state machine workflows?

What is the difference between sequential and state machine workflows?

  • Comments 5

Since this is our second post to this blog, I thought we should start with something very simple. I am aware that most of you probably know the answer to the question in the title, but this post could help those who don’t know the answer or are not totally sure about it.

What could a state machine (workflow) be? Here’s the definition from Wikipedia:

 

State machine is a model of behavior composed of a finite number of states, transitions between those states, and actions. (from http://wikipedia/wiki/State_machine).

  

Let's explain that definition in a practical, easier to understand and to remember way.  When you wake up in the morning you are hungry (or you just want some coffee very badly). We could call this state a "Hungry" state. Then, after you had something to eat you transition from the "Hungry" state to another state called "Full". And that's the whole 'science' of state machines. If you think about it, every one of us is always in either one of those states :). You could also add some more states like "Half-full", "A little hungry", etc.

 

So, what can you use state machine workflows for? You can use them for basically every business process that consists of states. Take for example a simple Word document and its lifecycle. You upload the document to SharePoint document library and the 'state' of the document at that point could be "Submitted". After document is submitted you can assign it to a user to approve or reject it and you get two more states: "Approved"/"Rejected”.

 

Norm Estabrook mentions an even better example of state machine workflows in his podcast about VSTO SharePoint workflow. Here is except from the recording:

 

"On the other hand, the steps in your solution may be random in nature and never really have a clear ending.  For example, the participants in an HR workflow might move an employment resume from state to state. The resume might be in a state of being considered, interviewing, or archiving for future.  The resume might be re-activated or updated at any time. Because there is no linear path of steps for the resume, it would be excessively hard to produce conditional rules to capture all possible paths.  In these situations, you would want to manage your workflow as a series of states and transitions.  Use the state machine workflow template to get started there."

 

When should you use state machine workflows? This is kind of a hard question to answer. You could use state machine workflow when for example a document requires multiple reviewers (legal, marketing, etc.) that may sign off on the document in any order. More complex state machines may open up different workflow paths depending on intermediate state.

 

How about sequential workflow? Sequential workflows are definitely much easier to design and maintain than state machine workflows. The only difference between a state machine workflow and sequential workflow is that in sequential workflow the flow goes from first activity to the next until end of the workflow is reached. In between you can branch the workflow, for example use IfElse or While activity, etc.

 

What type of workflows are you using more frequently - state or sequential? Are there any rules on when to use specific type of workflows?

 

Peter Jausovec

Leave a Comment
  • Please add 3 and 3 and type the answer here:
  • Post
  • Need proper information about state work flow and sequential workflow

  • good informative article! thank you!

  • Good description; examples really helped

  • Need more information on this topic!!

  • nice and explains clearly.. Thank You!!

Page 1 of 1 (5 items)