Pravin Indurkar

Why State Machine Workflows

 

Many people I have talked to have asked me why was there a need for state machine style of workflows. Here I am trying to put down some of my thoughts for the reasons why we felt the need for having the state machine style of workflows in Windows Workflow Foundation.

 

If you look generally at the business process landscape you will find that end user requirements have changed. They are no longer satisfied with simple business process automation. They want much more than automation. In my experience there are 3 main categories of requirements.

 

  1. Flexibility
  2. Visibility
  3. Control

 

 

Flexibility

 

Businesses today need to be agile and the business processes that they use constantly change to keep pace with the demands of their customers. Moreover for small businesses to compete their ability to be agile in responding to customer needs is what distinguishes them from their bigger competitors. Thus there is a need to create business processes that are flexible and accommodate a variety of situations. Often the business processes contain a prescribed path to the end goal but then there are a lot of alternate ways the same goal can be achieved. For example a Purchase order can contain a prescribed path where the PO goes from being create to approved to shipped to completed. But then there a multitude of other ways in which the PO can be completed. The PO can get changed, or back ordered or canceled and then ReOpened. All these paths must be accounted for. Just to put things in perspective. We did a study of the purchase order process of a small business and found that there was one traditional order fulfillment path but then there were about 65 different variations on the same process depending on the nature of the order. Trying to hardwire such a large number of alternate paths is not only difficult it is almost impossible. Traditionally there are two ways in which this was dealt with. Either the business process was hard wired to accommodate all the paths, making the implementation of the business process extremely complex, brittle and hard to maintain. In the other way the alternate paths are simply not dealt with and any situation of the ordinary was dealt outside the domain of the process. When dealt outside the process all the benefits like tracking, visibility etc were lost. Most often people create manual systems to track such out of the ordinary situations.

State machine workflows provide an easy way to create these complex business processes easily. In a state machine the idea is not to hardwire the different paths a process can take but rather to simply account for all the possibilities. The way you do it is by providing event handlers for each of the external events that can influence the process. Within each event handler you can put logic to respond to that event. You can then group the event handlers into logical states of the process. Each state corresponding a to a milestone in the process.

 

 

Visibility

 

In a connected world the ability to provide visibility into a business process to your partners  and customers is a very important competitive advantage. It also helps a business internally to measure key performance indicators and help in continuous improvement.

 

Once you have implemented your process the most important thing to do is to provide visibility into the running instance of the process. Without providing that visibility the process will be pretty much useless. In a lot of cases business processes are specifically built with visualization in mind. In some cases a whole layer is built to simply interpret the running instance of the process and provide visibility. All these approaches are fine but when you consider a flexible process which is changing frequently, the interpretive layer would have to change frequently too to make sure that the visualization is in sync. Also the knowledge of the business process is duplicated, once in the visualization layer and one in the process execution layer. This is not a very desirable way to build business systems.

 

Another important reason for providing visualization is to make sure that the users who are interacting with the process have all the right context to take any actions they want to. An ideal visualization must provide information about the past steps in the process, the current context and some information about the likely future. A business process must be built so that all these three aspects (providing the past, present and the future) are easily possible.

 

State machine workflows offer a very nice and effective way to query the process. Moreover there is no interpretive layer that needs to be built around it. The current state of the business process is the current state of the state machine. You can figure out the past steps by simply looking at the states the process has been through. In order to figure out the future you simply have to find out the possible events that can be received in a state and the possible transition from the current state. As you can see the amount of work that needs to be done to provide information is not much. The information about the process need not be duplicated in a visualization layer. You can see the order processing state machine example or the Interactive voice response application that are available for download. The entire Visualization layer is completely agnostic of the process. If any change is made to the process there is no need to change the UI it can simply query for the structure of the new process.

 

 

Control

 

Control almost seems paradoxical when we just talked about flexibility. The control we are talking here is the ability of the end user to control  a running instance of the process. For instance think of the PO process where the PO process owner wants to skip the approval step. Or may be a PO is important enough where an additional approval is required for which the approval step needs to be repeated.  Such type of interaction patterns require a kind of control that the end user must have on the execution of the process.

 

State machine workflows provide you the ability to control the execution. A user can skip a state or jump to any other state in the process. Trying to provide this kind of control in a sequential workflows would mean hardwiring those paths in the process. But again that would mean that the flexibility is lost.

 

Overall State machine workflows provide a very easy to use and useful paradigm. Also it is not something new that you have to learn. State Machine have been in use since the advent of computing and all of us have used them. Even in doing business process analysis all of us have drawn a state machine of the process on paper and then implemented it in code. What we offer in Windows Workflow Foundation is not only a way to create those state machines in Visual Studio but also a way to execute them.

Published Sunday, September 25, 2005 7:26 PM by pravini

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

CG said:

Good Article

First of all, it is good that finally someone is talking about State Machine based Processes. Over the last couple of years a lot of my work has been in the B2B Enterprise BPM space with a State Machine based process model as the center piece. Most Workflow models are "sequential" in nature and I was always left wondering if the approach I have been taking was wrong.



Apart from the Flexibility, Visibility and Control aspects of State Machine based Workflow model here are some additional aspects -

1. One perspective is that State Machine based models are good for representing High Level processes and a "Sequential" based model is good for detailed aspects.
* Example is a Purchase Order / Shipment Management process where the High Level process represents an Order's Lifecycle from New to Close ( good for a Business Analyst since thats what he is looking for ). A Sequential model could detail all the steps which happen when the Order is being accepted by the Supplier.
2. A State Machine model clearly distinguishes between the "end state" after an Event has happened - which is the State and the fact that a "sequenced" list of things need to be done when the Action happens.This makes it similar to how one would design on paper.
3. State Machines fit very well in the Human to System Workflow space - since humans are largely looking at "Current Status" and " What can I do next" which is very much what a State Machine Process Model provides. Here is a good article ( from the J2EE world ) on the State Machine vs Message based WFMS.

http://www.theserverside.com/articles/article.tss?l=Workflow
September 27, 2005 9:57 PM
 

DC said:

When is workflow scheduled to work with VS 2005 RC?
September 28, 2005 10:11 PM
 

Ariel Schapiro said:

Nice Article!!!

About the first comment, when you say "State Machine based models are good for representing High Level processes and a 'Sequential' based model is good for detailed aspects"; maybe thats related to the fact that in Sequential Workflows, the workflow controlls the sequence, while in state machine workflows, users controll the sequence. I Have posted ideas sumarized ideas like this here: http://staff.southworks.net/blogs/ariel/archive/2005/10/27/What_style_of_Workflow_should_I_use.aspx

Is logic to say that users operate in high level processes and they have its control, but if you go to detail aspects of the business logic, you have the machine processing it for you.
November 7, 2005 10:22 AM
 

Wei Shi said:

In the sentence "and any situation of the *ordinary* was dealt outside the domain of the process", should 'ordinary' be 'unordinary'?
November 24, 2005 3:46 AM
 

Sundeep Raina said:

This is the very nice link and had got enough idea about the working in workflow
i have one query ? can i ask ?
June 3, 2006 6:17 AM
 

Vidya N said:

Very good article in easy to understand words without using any technology or tool 's perspective

January 18, 2008 5:29 AM
 

Taklikar AH said:

Very good article that helps understanding the usage of the State Machine Workflows. Thanks.

April 29, 2008 6:47 AM
 

Living .NET... said:

Naming convention in Workflows Workflow activities should be named appropriately. As much as possible

July 16, 2008 3:52 AM
 

Living .NET... said:

Naming convention in Workflows Workflow activities should be named appropriately. As much as possible

December 28, 2008 2:00 AM
 

Venkatesh T said:

hi Pravin

i have created the sample state machine workflow, with two states. the first state has state initialization and event driven activity, and the second state has state initialization. when start the workflow, it works fine at the initial state. when i raise a event using the handle external event activity it doesn't move to next state.

I know that i have made a mistake, but couldn't able to trace. could you help me.

Thanks in advance

Venkatesh

April 23, 2009 8:08 AM
 

Pravin Indurkar Why State Machine Workflows | Paid Surveys said:

May 28, 2009 7:06 PM
 

Pravin Indurkar Why State Machine Workflows | Quick Diets said:

June 9, 2009 11:03 PM
 

Pravin Indurkar Why State Machine Workflows | unemployment office said:

June 16, 2009 4:05 AM

Leave a Comment

(required) 
(optional)
(required) 
Submit

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker