July 2006 - Posts

Recursive Composition

The Tampa Code Camp last weekend was fun, however I had many questions concerning Recursive Composition from the second session I did on human workflows. Here is the low down...

Sometimes multiple states need to use the same event. If you look at the model used in my previous blog, there are two states, "WashingBay" and "WorkOnAutomobile". These states need the same event to process payment once either them has been completed. Instead of adding a "ProcessPayment" event to each state, it makes more sense to allow each state the ability to inherit the event from a parent state. This is a two step process.

1. Add a new state to the machine state workflow, and give it a name that generalizes what child events it may contain.

2. Add an event to the new state that needs to be inherited from other states.

At this point, any states that need to inherit the event from the state can simply be dragged and dropped within the parent state. Once this is done correctly, each state will be readily seen as children of the parent event. Once each child state is active, they will able to inherit the event from the parent state.

Skip And Rework Pattern

I recently took my jeep to get the oil changed. While I was there, I realized that garage's business process model would serve as a great demonstration of "how" and "why" to implement a Skip/Rework Pattern for a State Machine workflow, at tomorrow's code camp in Tampa.

Here is the model... Oil Change

While I was giving the clerk my contact and payment information, they asked me if I would approve any needed work that they felt the jeep needed up to a certain amount. Obviously they would let me know before performing any additional service(s). If I did not approve needed work up to a specific amount, they would have to spend more time explaining what needed to be done and if they were to busy possibly removing my car from the bay to service another waiting customer. I would then have wait or make another appointment for a later time.

The Skip and Rework pattern is demonstrated by skipping the normal flow for the RecommendingAdditionalServices event, and getting the customer to approve or deny the additional service(s) within the ServiceApproval state.  Instead, needed services can be done immediately by setting the active state to WorkOnAutomobile, directly from the ChangeOil state.

The code do set the state active is pretty simple. I found the above code in Paul Andrew's book, and modified it to fit. The code above is wired to a button that allows the manager to bypass getting approval and sends the car directly to get service(s), because the customer already gave approval up to a certain estimate.

I first check that the Customer has given approval. Then I declare the SetStateEventArgs and pass the state I would like to set as the active state. The event to set the state is raised by calling the EnqueueItem for the workflow instance, passing the arguments for the state that needs to be set.

Learn About WF July 15th, In Tampa, Florida

The next Florida Code Camp is just around the corner! This month's "Geek Fest" takes us to Tampa, Florida where geeks of all ages get to learn about the latest and greatest technologies. With the new .Net Framework 3.0 CTP just released, this event could not have been scheduled at a better time. I will be giving two sessions focused on WF... One session will explain what Windows Workflow Foundation is all about, while pointing out key features of WF and how workflow styled applications can benefit from utilizing the framework. My second session will be focused on Human Workflows, the role they play in today's business processes and how they are built using WF. If you are in or will be in the Tampa area, make sure you do not miss this free event. To register, click here!