Sunday, March 22, 2009

 

Writing programs for the workflow domain

Jetfire is a DSL (domain specific language). So what domain are we talking about?

When we started Jetfire, the goal was to create a language that makes workflows easy to write. I can say without reservation that we have achieved that goal. Let's review the differences between Jetfire and C#.

  1. Jetfire is based on C#, so that programmers can easily write it.
  2. The keyword 'workflow' replaces 'class'. 'workflow' is used to activate first class support for workflow constructs.
  3. Dynamic Access Modifiers are used to make class members public/private depending on who is using the class.

The Jetfire domain specific language incorporates first class support for workflow constructs.    

Let's review some examples of how Jetfire simplifies writing workflows.

Example 1: States – Some workflows are state driven. Jetfire Methods include a new type of method: the state method. 'enterstate' is a keyword used to promote the workflow into the specified state.

public workflow MyFlow
{

    // 'Start' state

    Start()

    {

        // place code to be executed when the state is entered.

    }

    // constructor

    public MyFlow()

    {

        // put the workflow into the Start state

        enterstate Start()

    }

}

Example 2: Dynamic Access Modifier example using states – the AddData method is public when the workflow is in the Start state. Otherwise, the AddData method is private.

private ArrayList dataList = new ArrayList();

// method 'AddData' has a dynamic access modifier

public void AddData(string data) : states(Start)

{

    this.dataList.Add(data);

}

Example 3: Dynamic Access Modifier example using access – the DoSomething method is public if the logged in user has the Role 'Approver'. Otherwise, the DoSomething method is private.

public void DoSomething() : access("Approver")
{
    ...
}

These are some powerful examples how a domain specific language can simplify writing workflows.

Labels:


Comments: Post a Comment





<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]