Click here to Skip to main content
Email Password   helpLost your password?

Introduction

This article is intended for the audience who is in seek of conceptual knowledge about Windows Workflow. It starts from programming history, travels into architecture overview, internals, implementation path, etc.

Background - Programming History

Background

The current SOA (Service Oriented Architecture) trend is entirely different from machine language of the late 60s. SOA is an architectural style whose goal is to achieve loose coupling among interacting software agents. A service is a unit of work done by a service provider to achieve desired end results for a service consumer. Both provider and consumer are roles played by software agents on behalf of their owners. SOA concept leads to the current Web service technology with more application inter-operability.

SOA - Industry Revolution

Service Oriented Architecture (SOA) is a hot topic right now. Many companies and vendors are planning to move into an SOA environment because of the flexibility this technology offers for adapting systems to business process and technology changes. SOA-based solutions provide configurable workflow to enable customers to easily adapt processing to changing business requirements without time-consuming and costly customization. This not only simplifies and reduces the cost of implementation and maintenance, it ensures all adaptations carry forward through system upgrades, further extending system life and improving return on investment.

Workflows in SOA

An important architectural style for constructing enterprise applications is to use transactional workflows in SOA. In this setting, workflow activities invoke distributed services in a coordinated manner, using transaction context-propagating messages, coordination protocols, and compensation logic. Designing such transactional workflows is a time-consuming and error-prone task requiring deep subject matter expertise. Aiming to alleviate this problem, the paper introduces a new analysis and design method that identifies recurring architectural decisions in analysis-level process models, models alternatives for these decisions as reusable, platform-independent patterns and primitives, and maps the patterns and primitives into technology- and platform-specific settings in BPEL and SCA.

Technical Overview

Workflow is nothing but a sequence of tasks. A workflow describes the order of a set of tasks performed by various agents to complete a given procedure within an organization. It is heavily used in the business process flow. Repetitive workflows are often automated, particularly in organizations that handle high volumes of forms or documents according to fixed procedures. In fact, workflow management is an important part of business process management (BPM).

Before Workflow

In 'n' tier architecture, the system can be composed of multiple layers / tiers based on the system requirement and capabilities. Fundamentally, we can think of FOUR basic tier in the modern Web service system. It is represented as:

User Interface takes care of the presentation layer, which receives the input from the end user and supplies to the server. Web services layer is the receiving channel (as well as the router) from the client to the server. Server contains the actual business logic to build the application and database related operations are segregated into the last layer.

After Workflow

In the presence of the workflow layer, the business process can be articulated in the below structure:

The additional layer manages the workflow of the business execution in a highly configurable methodology. It gives a lot of benefit to achieve the BPM (Business Process Management) model.

Windows Workflow

Towards SOA journey, Microsoft built its next generation technologies in .NET 3.0 and above. 3.0 Framework contains FOUR major pillars for User Interface (Presentation), Server (Web Services), Business process (Workflow) and Security (Card Space). The related products are named as Windows Presentation Foundation (WPF), Windows Communication Foundation (WCF), Windows Workflow (WF) and Windows Card space.  Let us focus on WF in this article.

WF != WWF

On comparing workflow with presentation (WPF) and communication foundation (WCF), it should be coined as Windows Workflow Foundation (WWF). But it is not so. In general, WWF refers to wrestling...

... or World Wildlife Foundation:

Definition

Windows Workflow Foundation (WF) is the programming model, engine and tools for quickly building workflow enabled applications on Windows. Workflows coordinate work performed by people and by software.

Concepts of Workflow (WF)

Workflow & Activity

Activity is the key term used in workflow because activities are the primary building blocks of workflow. An activity is a discrete, reusable component that is designed to fulfill a defined process. Workflow includes a set of standard activities that you can leverage within your application. At the same time, it is encouraged to develop your own custom activities to solve the specialized business challenges.

Technical Representation

Technically, workflow and activities are related in the below class diagram:

In abstract, a workflow is a .NET class:

Workflow Types

In general, workflow persistence allows to automatically save the state of running workflow instance and then reload them at a later time.  The use of persistence is especially important for long running workflows where a workflow can be unloaded from memory while it is idle and waiting for an external event.

Windows Workflow foundation supports two main types of workflows.  They are:

We know that every sorting algorithm has the best case scenario. Similarly, the two types of workflow have their own best usage.

Sequential Workflow

Sequential workflows are best used when the exact sequence of tasks is known at design time. It typically represents the flow chart model as below:

State Machine Workflow

State machine workflows are designed to easily react to the external events. They are especially useful for problems that involve human interaction since the exact sequence of tasks can't be determined at design time. Typically, its state diagram (in design pattern) is:

Comparison

The comparison factors of these two workflow types are tabulated as below:

Area Sequential State
Processing Order Sequential structure prescribes processing order External events drive the processing order
Methodology Prescriptive in nature Reactive
Trigger Sequential formal way Event driven
Best fit Automation Scenarios Exception handling

Typical execution model of these two workflow types are drawn as:

WF - Architectural Concepts

The key architecture components of workflow foundation are listed as:

Workflow Foundation

Windows Workflow Foundation has THREE key components. They are:

  1. Base Activity Library
  2. Runtime Engine
  3. Runtime Services

Base Activity Library

It contains the fundamental or base assembly or library to manipulate the custom activities in WF. There are two categories of base activity library. They are:

  1. Basic
  2. Composite

Basic library contains all the single level operations like code, delay, trigger point to invoke service methods, etc. Fundamentally, it is the single component workflow without any complexity.

In terms of composite library, there is a combination of one or more activities in the integrated fashion. As an example, there are some conditional activities like If Else, Parallel, Replicator in this group. It is illustrated in the list below:

 

What do you mean by the custom activities? Custom Activity is a class, which is derived from an existing activity or activity itself. The technical implementation methodology is represented in the class diagram below. The execution method should be overridden at the custom activity class.

class FileCopyActivity : Activity {
     override Execute();
     }

In the following steps, we will see how the record is processed internally through FOUR core Web service components.

Runtime Engine

Let us see how runtime engine is triggered by the execution of the source code. It starts with the creation of the run time instance with the existing library as:

{
    WorkflowRuntime runTime = new WorkflowRuntime();
}

Workflow instance is created on top of the created workflow runtime instance, which has just been created. So the code looks like:

{
    WorkflowRuntime runTime = new WorkflowRuntime();
    WorkflowInstance inst = runtime.CreateWorkflow(typeof(WF1))
}

The third statement Start triggers the execution of the workflow instance at the created runtime instance. The actual execution kick starts here with the usage of base activity libraries.

{
    WorkflowRuntime runTime = new WorkflowRuntime();
    WorkflowInstance inst = runtime.CreateWorkflow(typeof(WF1));
    inst.Start();
}

Runtime Services

As the framework, collection of objects actually do most of the work in Microsoft Workflow(WF). In WF, there are some required services that are always present, if the developer adds one that is used, otherwise a default is used. For example, the DefaultWorkflowSchedulerService is the default implementation of the required WorkflowSchedulerService. Some other RuntimeServices are optional but provided out of the box like the SqlWorkflowPersistenceService. If not provided, there is no default and this functionality is unavailable. The third kind of RuntimeServices is the custom RuntimeServices usually developed in combination with a custom workflow Activity. These services can use the WorkflowRuntimeService as a base class although this is not required and they can derive from another class if so desired. Use the WorkflowRuntime AddService function to configure the WorkflowRuntime.

Model Driven Development

Overview

Workflow promotes the model driven development. Model driven architecture (MDA) is the emerging model in the next generation software development. Model Driven Development (MDD) is an approach to application design and implementation. MDA encourages efficient use of system models in the software development process, and it supports reuse of best practices when creating families of systems. MDA is a way to organize and manage enterprise architectures supported by automated tools and services for both defining the models and facilitating transformations between different model types. In history, MDA (Model Driven Architecture) was launched by Object Management Group in 2001, is a kind of domain engineering, which supports model-driven engineering of software systems.

Four Principles of MDA

At the technical core, MDA are the concepts of models, of meta models defining the abstract languages in which the models are captured, and of transformations that take one or more models and produce one or more other models from them. Four major concepts are linked in the below image:

Model

A model represents some specific purpose in mind. It is related to the thing by an implicit isomorphism. A model can be a view of a certain aspect of a software system.

Meta Model

Meta model is a special kind of model that specifies the abstract syntax of a modeling language. In MDA context, it is expressed using Meta Object Facility (MOF).

Model Transformation Specification

It determines how a set of output models results from a set of input models.

Transformation Record

It links groups of objects in the input models to the groups of objects into which they are transformed in the output models. These links are associated with model transformation specification elements that relate the groups concerned.

Workflow Model

Workflow promotes the model drive architecture (MDA), which is the emerging model in the next generation software development.

Case Study in WF

Let us take the defect tracker tool to illustrate the power of Workflow.

Pre Workflow

Prior to the workflow concept, a defect tracker system was built in 6 tier architecture, which has User Interface, Web Service, Transaction, Business, ADO and Database layers. It is represented as:

Post Workflow

On building the workflow system, the defect tracker is quite dynamic and customizable with the customer demand with almost nil level of code change. In the presence of workflow, the business process flow is drawn / drafted in the predefined template. Later, the business flow is dynamically altered without making the major change in the source code. The tracker with workflow concept would be conceptualized as:

Benefits

Microsoft WorkFlow(WF) represents a completely new way to develop applications. It is declarative, visual and infinitely flexible. It promotes a model that cleanly separates what to do from when to do. This kind of separation allows the user to change the workflow model (when) without affecting what. Fundamentally, WF gives the benefit in terms of productivity, quality, flexibility and development cost.

Workflow is not a new concept. But, Microsoft spent years in developing a workflow foundation and provides it to us without cost, it is an event worth nothing. Using this fantastic framework, it is easy to build an exciting new/next generation of workflow enabled applications

Productivity

Workflow system makes a vital improvement in the productivity (output vs input). In case of the above tracker system, the business changes can be done within a shorter time frame when compared with non workflow system. So, by putting a tiny amount of effort, the output, i.e. product enhancements can be achieved quite easily.

Quality

Quality is related to the excellence factor of the product. Let us assume the business flow change, i.e. defect stage processing changes to be implemented in the above defect system. In the absence of the workflow system, the manual changes are required in most of the server code. After this development changes, the system requires the tremendous effort in terms of validating the new functionality and the fixes accordingly. The same scenario can be easily and successfully handled through the workflow process. It assures the quality of the business changes with less validation and effort. Thus, workflow exhibits higher amount of the product quality.

Flexibility

Workflow system has the high range of flexibility (quick adaptability) in the product. Software development consists of two phases:

  1. Development
  2. Maintenance

Workflow has the capability to build the flexible (to implement the changes rapidly) system in both phases. In the above tracker system, the creation of the business rule and later updation can be done in a quick fashion using the workflow technology.

Development Cost

Cost is the ultimate factor of any software development. Workflow reduces the overall project effort, which directly shrinks the development cost. If we take the above tracker as the case study, we get the better picture about the development cost involved. If we built the business process using workflow technology, the development effort will be minimal and so the cost will get reduced. Fundamentally, Workflow model makes the revolution not only in the next generation technology, but also drastic reduction in the development effort and cost.

Points of Interest

Hope it will be interesting to know the key concepts and workflow core ideas, instead of the traditional path. Herewith, a s(i)ample workflow application has been incorporated for hands on purposes.

History

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralNice article
Member 2369186
19:33 18 Jan '09  
to kick strat Wf
GeneralNice article.
julius-dias
19:27 28 Nov '08  
Thanks for the excellent article.

1. Was curious about the color of nodes in your chart. Do they signify anything ?
2. I got somewaht confused by your chart though. You have indicated the gradual move from byte code to assembly to SOA. Where would COM, Webservices fit in ?
GeneralGood article,
Tefik Becirovic
22:03 11 Nov '08  
but I miss couple of words about the Sample Source and I stil miss years labels on the time axis of the Programming History.
If you can correct wwfBasic.jpg and wwfComposite.jpg images resolution yet, all will be perfect.
What about *.PNG? Simple snap a screen, paste to the Paint, crop and save as PNG.

Regards
Tefik Becirovic
GeneralRe: Good article,
GanesanSenthilvel
15:33 13 Nov '08  
Thanks for the feedback Tefik. I didn't put the years label because it shows the trend. Typically the intersection of x and y axis, represents 1960s.


Last Updated 11 Nov 2008 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2010