In Valid Logic

Endlessly expanding technology

Windows Workflow Foundation

Lately, I've been looking at using Windows Workflow Foundation. Figured it out soley based on webcasts and articles wasn't getting me too far, so I picked up a copy of Presenting Windows Workflow Foundation and have started reading through it.

Overall, WWF looks very exciting. It makes it much easier to logically break up the functionality of a program and visually see how all the parts are connected. It is not suited for all types of programs, since there is a certain threshold of complexity where the cost of taking longer to develop (creating activities and wiring it up would take a little longer than straight code) would not be justified with a basic operation. More complex things can greatly benefit as it is more visual, easier to see how things separate, debug activities since they are more encapsulated. And on top of that, the workflows are dynamic so they can easily be changed to meet certain customers needs.

After reading through some of the book, I decided to take a stab at writing my own workflow and some of my own activities. One of the places I'm looking at using WWF is for Community Server :: Mail Gateway, so I thought I'd start off with a workflow to process messages. After almost 6 six hours last night, I finally had a workflow that would loop through the To/CC and find valid To addresses and a valid sender. All this for code that would have taken me about 10-15 mins to write. This amount of time in development is not realistic. Most of it was starting with something, realizing it wasn't the best way, and then starting over. I wrote some of the activities probably half a dozen times as I was figuring out the best ways to do the processing and pass the data around.

So after the 6 hours, I had a workflow, with the activities, it all compiled without any issues, so I decided to fire it off. SPLAT. Crashes upon execution with a type invocation error (a common error I was having, not very explanatory, but I'd usually track it down, though before it was always a compiler error, not runtime). After that, I gave up and went to bed.

After thinking about it some, I think I've realized my problem. I was using the workflow to desribe the functionality of my program at too low of a level. IE, I created an activity that used while activity to loop through a collection and then fired off another custom activity to process each item. This is far more complex than it really needs to be, and not much is gained by it. Instead, I should use the workflow to describe a higher level of functionality. So I should create an activity that simply does the loop and processing all at once, in code, and then use the workflow to describe what operation it moves onto after that is done.

Additionally, I don't think Windows Workflow Foundation is ready for me to be putting into an application that is already stable and in production. The release we are looking to use it for is still quite a ways off (Community Server v3.0), but I don't want to take something that is fairly stable right now, and add in this beta library that is still changing as a core dependency. Already, I've found some example code in the book (which was written even before Beta1) that is no longer valid (current is Beta2). Also found a couple of issues with the designer where it would be testy on listing activities I'd written or some errors where all I could do is close Visual Studio, then re-open it and it would be fine.

In summary, would have to say that Windows Workflow Foundation could certainly become a powerful tool to help make complex operations more dynamic and logical. Workflows are best suited for complex operations and to describe them at a somewhat high level, as introducing workflow to these tasks adds a certain amount of additional complexity, but the advantage is that overall, it gains visual flow (more human unstandable), better separation/subdivision, and the ability to be dynamically changed.

Wednesday, March 22, 2006

blog comments powered by Disqus