RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Windows Workflow Foundation Essentials

Applications that contain business processes and rules can benefit immediately from Windows Workflow's diagrams, class libraries, runtime, rules engine, and customization capabilities.

t can be tough keeping up with all the new technologies released by Microsoft, but Windows Workflow Foundation (WF) is a technology you do not want to miss. This article demonstrates the benefits of Windows Workflow and invites you to roll up your sleeves and get started creating your first basic workflows.

Windows Workflow Foundation (WF) is a general-purpose programming framework for creating reactive programs where business rules and flow of control are represented graphically. As you shall see, the WF programming model separates the what from the when.

WF is one of four technologies—along with Windows Presentation Foundation (WPF), Windows Communication Foundation (WCF), and Windows CardSpace—released by Microsoft as part of the .NET 3.0 Framework. The "3.0" designation is confusing to many developers because it seems to indicate that these technologies must be used with a new version of the .NET Framework. In reality, they work with (and currently depend on) version 2.0 of the .NET Framework as shown in Figure 1.

Figure 1. NET 3.0 Dependencies: Although counterintuitively named, the .NET 3.0 technologies work with and depend on version 2.0 of the .NET Framework.
The problem with the 3.0 moniker is that some development shops choose not to use these new technologies because they think they need to install a new version of the .NET Framework and don't want to make that shift in the middle of their current development cycle. Once again, Microsoft has shot itself in the foot with another naming faux pas.

In reality, these 3.0 technologies are all add-on technologies that work with the .NET 2.0 Framework and Visual Studio 2005. You can use these technologies in the same way that you use third-party add-ons for the .NET 2.0 Framework.

Windows Workflow Benefits
From a pragmatic perspective, new technologies must be ready for prime time and provide tangible benefits before they're useful. WF hits the mark on both points. Of all the .NET 3.0 technologies, WF is the most complete in terms of functionality and design-time experience.

Here are some of the benefits you reap from WF:

  • It provides a higher level of abstraction and visual representation of your business processes that make them easy to create and understand—both by developers and business domain experts.
  • It's easy to change the flow and rules associated with business processes, often without having to recompile.
  • WF programming encourages developers to create a core set of well-tested activities that you can reuse in multiple applications.
  • Compared to their UML counterpart—Activity Diagrams—WF diagrams are first-class software artifacts that don't become outdated and diverge from business process logic because they are the business process logic.
  • The Windows Workflow runtime provides a robust, scalable environment in which your workflows execute. For long-term processes, workflows can be persisted to a database when they become idle (optional) and reactivated when an external stimulus occurs.
Activity-Oriented Programming
WF introduces .NET developers to the concept of activity-oriented programming. This programming model focuses on creating application functionality by combining sets of activities to accomplish a larger business process.

As you can see in the partial workflow shown in Figure 2, a workflow diagram contains activities such as validateProductActivity, sellProductActivity, backOrderProductActivity, and shipOrderActivity, each of which executes a single unit of work in a workflow.

Figure 2. Workflow Diagram: A workflow diagram contains activities, each of which performs one part of a business process.
Using the WF designer you can add activities to a diagram and specify the flow of the work to be executed using conditional branching and other flow-of-control constructs that execute based on rules that you specify. This is a powerful approach that takes your application processing code "out of the weeds" and elevates it to a place where it is easy to understand and configure.

Getting Started in Windows Workflow
To get started with Windows Workflow you need the following products on your development machine (installed in the order listed):

  • .NET 2.0 Framework
  • Visual Studio 2005
  • .NET 3.0 Framework
  • Visual Studio 2005 Extensions for Windows Workflow
The .NET 3.0 Framework has over 350 classes defined in three WF-specific assemblies:

  • System.Workflow.Activities
  • System.Workflow.ComponentModel
  • System.Workflow.Runtime
When you install the Visual Studio 2005 Extensions for Windows Workflow, it adds workflow-specific project templates and item templates to your development machine that you can select when you create a new project or add a new item to a project.

After installing the prerequisites, you're ready to create your first workflow. The following sections outline the steps involved as well as best practices as you go through each step.

Editor's Note: This article was first published in the November/December 2007 issue of CoDe Magazine, and is reprinted here by permission.

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date