Tuesday, September 05, 2006
« More DNR TV shows | Main | Answers to some CSLA .NET questions »

Several people have asked me about my thoughts on the Microsoft .NET 3.0 Workflow Foundation (WF) technology.

 

My views certainly don’t correspond with Microsoft's official line. But the “official line” comes from the WF marketing team, and they'll tell you that WF is the be-all-and-end-all, and that's obviously silly. Microsoft product teams are always excited about their work, which is good and makes sense. We all just need to apply an "excitement filter" to anything they say, bring it back to reality and decide what really works for us. ;)

 

Depending on who you talk to, WF should be used to do almost anything and everything. It can drive your UI, replace your business layer, orchestrate your processes and workflow, manage your data access and solve world hunger…

 

My view on WF is a bit more modest:

 

Most applications have a lot of highly interactive processes - where users edit, view and otherwise interact with the system. These applications almost always also have some non-interactive processes - where the user initiates an action, but then a sequence of steps are followed without the user's input, and typically without even telling the user about each step.

 

Think about an inventory system. There's lots of interaction as the user adds products, updates quantities, moves inventory around, changes cost/price data, etc. Then there's almost always a point at which a "pick list" gets generated so someone can go into the warehouse and actually get the stuff so it can be shipped or used or whatever. Generating a pick list is a non-trivial task, because it requires looking at demand (orders, etc.), evaluating what products to get, where they are and ordering the list to make the best use of the stock floor personnel's time. This is a non-interactive process.

 

Today we all write these non-interactive processes in code. Maybe with a set of objects working in concert, but more often as a linear or procedural set of code. If a change is needed to the process, we have to alter the code itself, possibly introducing unintended side-effects, because there's little isolation between steps.

 

Personally I think this is where WF fits in. It is really good at helping you create and manage non-interactive processes.

 

Yes, you have to think about those non-interactive processes in a different way to use WF. But it is probably worth it, because in the end you'll have divided each process into a set of discrete, autonomous steps. WF itself will invoke each step in order, and you have the pleasure (seriously!) of creating each step as an independent unit of code.

 

From an OO design perspective it is almost perfect, because each step is a use case, that can be designed and implemented in isolation - which is a rare and exciting thing!

 

Note that getting to this point really does require rethinking of the non-interactive process. You have to break the process down into a set of discrete steps, ensuring that each step has very clearly defined inputs and outputs, and the implementation of each step must arbitrarily ensure any prerequisites are met, because it can't know in what order things will eventually occur.

 

The great thing (?) about this design process is that the decomposition necessary to pull it off is exactly the same stuff universities were teaching 25 years ago to COBOL and FORTRAN students. This is procedural programming "done right". To me though, the cool think is that each "procedure" now becomes a use case, and so we're finally in a position to exploit the power of procedural AND object-oriented design and programming! (and yes, I am totally serious)

 

So in the end, I think that most applications have a place for WF, because most applications have one or more of these non-interactive processes. The design effort is worth it, because the end result is a more flexible and maintainable process within your application.

Tuesday, September 05, 2006 11:24:24 AM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [4]  |  Related posts:
VS10 and SQL Express frustration
Silverlight 6 doesn’t matter
Why MVVM?
WinRT and business apps
WinRT and .NET
Architect training in May 2011

Tuesday, September 05, 2006 1:28:50 PM (Central Standard Time, UTC-06:00)
What you describe above, is a perfect description of sequential workflow. So obviously my Q is, Why wouldn't a state machine workflow be the ideal candidate for an interactive business process?
Tuesday, September 05, 2006 2:26:16 PM (Central Standard Time, UTC-06:00)
While it is possible to think of an interactive UI as a state machine, most of us don't. We think of it as an event-driven environment, and our tools enable that model very nicely, and have for the past 15 years or so.

I won't dispute that the WF team could work with the Web Forms and Windows Forms (and/or WPF) teams, along with the VS IDE team, to create a new UI development model that gives us similar drag-drop-and-double-click functionality to what we have today, but behind the scenes is really building a state machine workflow.

But given the rate at which Microsoft moves, we won't see anything like that for many years... I think it is likely that we'll see something along these lines in the web and maybe WPF worlds sooner - but then only for a "block mode" UI model like the web, not a model like Windows or AJAX.

The core problem is this: a truly interactive UI (like Windows) has so many possible states that a state machine becomes entirely unmanageable. The web, and one mode of WPF makes each page a state (more or less), and so the number of states becomes manageable - but the user experience, frankly, sucks rocks.

This is why there's this huge push in the web world to get to AJAX - to recapture the interactivity of Windows apps. And then you immediately re-enter this world where a state machine becomes unmanageable because you’d have hundreds, or thousands, of states…

I think there’s also a lurking issue here – regarding separation of UI from business logic. If WF is used to drive the UI, that’s great. But it still must defer all logic (validation, calculation, authorization, etc.) to some other layer or the result is unmaintainable – we know that from experience… But looking at how you’d use WF as a state machine manager for a UI, it surely is tempting to put your business logic into that workflow diagram too!

I think the end result is yet another way to create VB3 style applications – only with pictures instead of code…

But that whole debate is really a moot point. For any sort of truly interactive UI (Windows or AJAX), I doubt we’ll see workable tool support for so many years in the future that it really doesn’t matter…
Tuesday, September 05, 2006 2:58:58 PM (Central Standard Time, UTC-06:00)
Sorry to bother you again, but if I understood you right, we have 3 kinds of applications

Sequential Workflow - noninteractive processes

State Machine workflow - where simpler and fewer states have the ability to tie together multiple processes, and applications.

OLTP/Interactive UI/Applications - Where you are writing a huge smart wrapper around a database :) (or similar).

I still don't see why you feel state machine workflows have no place in today's architecture. Do we never have a need for workflows where we need to tie together disparate systems and people driven by data states?
Tuesday, September 05, 2006 3:21:37 PM (Central Standard Time, UTC-06:00)
OK, now you've changed the parameters of your question :)

I don't reject state machines or state machine workflows as being a bad thing - I just don't think we're likely to see them in widespread use for creating interactive applications. At least not until there's comparable tooling to today's event-driven tooling - so we're looking out many years in the future.

But that's not to say that state machine workflows aren't of value in the shorter term. In particular, in the area of EAI (enterprise application integration) - which is often known by its more trendy name: service-orientation :)

When thinking about service-orientation there are two thought models (ideally - though in reality there are three).

One is "inside the service", where the service is an interface to your application - and you might build that application/service using various techniques (OO, procedural, workflow, etc).

The other is "outside the service", where you are creating a system composed of services. This system could be constructed as a sequential workflow - and many will be. The best way to model such a system is to use a flowchart after all... But some of these systems, especially more complex ones, should benefit from a state machine approach rather than a procedural approach, because they'll be orchestrating communications with several disparate applications/services.

The third thought model (which ideally wouldn't exist) is that of a service consumer. This thought model presupposes that an application/service can call another application/service - and is wrong-headed in my view. What _should_ happen is that a "system" should be created (see the previous paragraph) that manages all interaction between appliations/services. If that's done, then there should never be the need for a service to call another service - because that type of coupling is fragile.

However, the reality is that most people use the first and third thought models, and not the second... In such a case, this "consumer" model IS the orchestrator that calls the other service. As such, it too can benefit from using a state machine - at least in the case where it is orchestrating calls to multiple applications/services.

I think, however, that it is debatable whether this last point actually makes sense... Most people who are using the consumer/service model are really building client/server apps - not service-oriented apps. As such, the consumer is really treating the service more like a stored procedure than anything else, and so the calling semantics aren't complex enough to warrant the overhead of designing for WF, much less for a state machine.
Comments are closed.