views:

46

answers:

1

I designing a project management tool, where you can track current status and such. Let's say a typical project flows like:

Create Project > Deliver Specs > Approve Specs > Start Development > End Development > Delivered (another flow from Deliver Specs could be > Reject Specs > Rework Specs > Re-deliver Specs)

There are many steps in between, but for simplicity I'll just leave it at that. Different user (groups) are allowed to do different tasks (ie: only developers can start dev or approve specs, the customer can create projects, etc.)

My initial design was that of a finite state machine, where you have states and each "task" is a transition taking the project to a different state. Ie:

[Dev Started] -> (End Development) -> [Dev Finished]
[Dev Finished] -> (Deliver SW) -> [SW Delivered]
[State] (Transition)

Some sample config code in PHP looks like:

$states = array (
    0 => array('name' => 'Project Created', 'transitions' => array(0)), 
    1 => array('name' => 'Specs Delivered', 'transitions' => array(1, 2))
    // ...
); 

$transitions = array (
    0 => array('name' => 'Deliver Specs', 'allowed_groups' => 'customer', 'next' => 1)) // ...
);

Now, that is kind of OK, but a developer typically doesn't approve the Specs are until they are towards the end of development. To get around that, I created duplicates of states, which "remember" whether the specs have been approved or not. Add to that user/group permissions and other stuff I have to keep track of, this is quickly becoming unwieldy.

Most projects can be fit into a relatively small number of "flows" which will be somewhat similar, but I want the code to be flexibile and extensible enough to handle more.

Does anyone have a better idea? Thanks in advance.

A: 

My PHP skills are all rusty, and I didn't get your question exactly, but I think it would be better if, rather than creating a finite state machine, you create a workflow structure/tree/graph as a separate object, and associate a project with a certain state in that structure. That way your workflows becomes really extensible. For example, you can add a new state to the structure, between two existing states say, without having to change anything else.

tathagata
Yes, I have it set up like that.The state stored in the project just references a state defined in the StateMachine class. And all transitions are also handled by the StateMachine class.
quantumSoup