Janakiram's profileStateless ComponentPhotosBlogLists Tools Help
    November 20

    Windows Workflow Foundation - New Kid on the WinFX Block

    I have been a BizTalk developer sometime back. I used it for one of the large B2B pilots that we did couple of years back. Obviously, I was curious to learn about WWF and figure out when and where to use it.

    Yesterday I presented a quick intro on WWF at MUGH User Group Meet here at Hyderabad.

    I want to explain this technology the way I understand it. I hope this helps some of you who are confused even after reading some intro articles on MSDN.

    Many of us write enterprise applications that has complex business logic. This business logic will obviously have a decent chunk of code that contains some conditional branching.

    Think of a scenario where an employee places an internal order for a new notebook computer. The system has to check if the employee is a full time employee before it sends a notification to the manager for his approval.

    After the approval process completes, it then goes onto checking the internal inventory for that specific product.If the internal stock is empty, the system goes about generating a PO and calls a Web Service to place an order with the vendor. Then it waits till the Web Service sends an acknowledgment with the order confirmation number and a tentative date of shipping. The process is completed by sending a mail to the employee with the acknowledgment details.

     

    Let’s translate the above scenario into a pseudo code.

     

    public void PlaceOrder(Employee e, Product p)

    {

       if(e.FTE)

       {

           if (GetManagerApproval(e,p))

           {

               Inventory i=InventoryServiceProxy.GetInventory(P.ProductID);

        

              if(!i.InStock)

               {

                  PurchaseOrder PO=new PurchaseOrder(p,1);

                  OrderAck Ack=OrderServiceProxy.SendPO(PO);

                  SendMail(“Placed New Order”,”Order #” + Ack.OrderNo +” Expected on ” + ACK.ShipDate, e.EmailID);

               }

            }      

         }

         // Rest of the code goes here

    }

     

    While the above scenario looks very normal and the code looks very familiar, think of some of the possible issues that may crop up over a period of time.

     

    • The company wants to allow even interns to place a new order.
    • The approval process now involves a procurement manager’s approval even before the employee’s manager approves it.
    • With the vendor providing local ware houses at each city, the company wants to do away with local inventory maintenance and wants to directly check with the vendor’s nearest warehouse.
    • For some strange reasons, the acknowledgement also needs to be sent as a SMS or IM alert to the employee.

     

    Unfortunately, our code has no capability to adapt to these requirements and align itself with the changing business requirements. Ideally we should isolate this kind of branching from core business logic.

    We should let an analyst or a business manager define and re-define this kind of branching. Actually this perfectly qualifies to be a Workflow. The business logic should have ‘hooks’ to these workflows that run outside of the context of the core business logic. Whenever the workflow needs to be executed, the biz logic should invoke the current workflow definition either synchronously or asynchronously based on the scenario.

    WWF efficiently lets a developer convert the decision branching part of the code into an independent and insulated workflow entity from the core business logic.

    Using the intuitive designer, any business decision maker can alter the workflow and persist it back into the system. The cool thing about WWF is that the workflow designer can be shipped with your app that runs independent of Visual Studio.  

    As I first mentioned in post, this is my initial understanding of WWF. If you feel I am inaccurate in conveying some of the points, drop a comment and I will be glad to go back to do my homework J

    The following WWF model depicts the logic that we discussed above.

    Comments (1)

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Picture of Anonymous
    mfcmahesh wrote:
    Hi Janakiram,
    Happy to see ur blog about WinFX. Exactly well said.
    Even this week I had complete WinFX training provided by micrsoft people in Dumlur R&D Center. Basically its for desicision making(WWF) and branching level of approvals etc. During the 4 days training, we were kept on asking about where we can exactly fit this WWF in our requirements. But still Its highly diffcult to simulate requirement for this WWF programming model.
    Why we need this new Programming model for descision making alone...??? becoz it cannot run by itself or UI part for getting input from the user,
    we have to consume either as dll or webservice right..??

    Mahes~
    BLR
    Dec. 10