Category Archives: Software Architecture

When to use Workflow?

Recently, I was design architecture for one of the project, the developer ask me simple question, “Why should I use Workflow?” and that stump me.

He, mean why all the fuss about Workflow, Workflow engine, Business process modelling and it can just go on. Why can’t we simply write the code to do that stuff. It clean, simple and testable, why increase the complexity by introducing new component to mange flow, which in turn, bring new learning curve, slow down’s the development, would have hidden pitfalls, and bring all the frustration to make it work.

Instead, why can’t we do what all that workflow does, simply in code?

Hmm, for couple of moment, I was benumb. It isn’t, that I do not know, why to use workflow, but the information is overwhelming. Where do I start to answer? If I go by text definition “Workflow is there to solve business process problem which..“, he surely, an’t going to understand it.

Taking deep breath, I said “I would get back to you on this, later”. Whew! Now, I was wandering whole night, how to explain it simple, Why to use workflow, what are eligible use cases for the use, and more important, when you shouldn’t use it (best case for over design).

This are the uses case I came of it,

  1. You have long running business process. 
    When I mean long running business process, I don’t mean the time, like day, week or months, but something which needs to survives restart of the hosting server.
  2. The flow of process keep changing frequently.
    Process is made up of several steps, and business users either keeps on adding up new steps, or change conditional flow, or re-order steps in process. As good architect, base of principle of volatility decomposition, separate out the things, which change frequently.
    Another use case would be, suppose, you are designing the product for news publishing, and each article goes to series of step of fact validation, proof checking, styling and then publish. This is what ‘x’ client does. When you try to sell to another client, they do the same publishing, but, in slight different steps. Aa ah! Prefect use case for workflow
  3. You need visual representation of the process.
    You business user can’t understand c#. They need some mechanism for not only to visual series of steps, but also change it visually. In who know’s all (expert) term, it call business process modeling.

Now, I have convince him to use workflow, now he need to bother about all lot of workflow items like states, process, steps, transition, trigger, conditional trigger, actions, state transfers, persistence, state queries, versioning , flow, sequential, parallel, and much more! Phew!

References

http://programmers.stackexchange.com/questions/103972/when-to-use-workflow-engines/103983#103983

http://programmers.stackexchange.com/questions/103972/when-to-use-workflow-engines

http://stackoverflow.com/questions/104099/when-to-use-windows-workflow-foundation