While researching on configurable workflows, I went through some readymade tools such as Windows Workflow or other opensource BPM/Workflow management tools. However one of my seniors suggested a (seemingly) simpler approach.
Start with a file based configuration of how the workflow should be. For an order management module, at a very simple state, this includes storing the present state and the next state. Based on the present state of an order, it could be pushed into the next state or cancelled.
This much is easy to implement. Now there's another requirement: When pushing an order from one state to another, there may be several things to be done. For e.g. generate an invoice, email the generated invoice to the client, make an entry in some table and so on and so forth. So there's the core action of updating the order state, and the supporting actions which make a complete business/use case.
One of the ways the senior told us is to simply write the necessary method names in the configuration file. So if the order has to move from created state to the approved state, the file would also capture a list of methods (maybe fully qualified) to execute before the state changed, or after the state changed.
How do I manage this?
An example can be of a csv file with the following columns:
I know this is complex, but I need some simple way of getting this to work. The ensuing complexity can then be managed.