tags:

views:

159

answers:

2

Hey guys,

I have a predetermined flow chart made up entirely out of boolean conditions and a bunch of logic to be performed in response.

The flow is unlikely to change much, but there is a small possibility that it will. (new steps might be introduced, or the order of conditions might change)

What would be the best approach to code this? A big set of nested if else statements? Workflow Foundation? Anything else?

Thanks, rauchy

+3  A: 

If flexibility is not a primary concern then you can go and just hardcode the whole flow chart logic. Simplest is often best. Structure your code according to the original flowchart's concepts, so it will be easy to see the analogy and make changes in the future if necessery.

Windows Workflow Foundation can be a good tool if you're already familiar with it or you're willing to take the learning curve.

Vizu
Re; WWF; I Don't mind the learning curve, I'm just afraid it might be overkill (architecture and performance wise)
Omer Rauchwerger
+3  A: 

Flow charts which have an acknowledged possibility of change invite a State Machine for implementation. Whether you go all the way to the State pattern or simply implement the state machine (data driven doesn't seem to have a justification YET in your described case) is implementation detail.

Tetsujin no Oni
That's what I thought at first, but then I remembered that the inner state object in the State pattern usually has an interface of operations that lead from one state to the other, which is usually doubled by the container object, whereas in my case, the only common interface is pretty much a boolean condition. So I'm not so sure how well State works here,
Omer Rauchwerger
thus the suggestion of state machine. Each state for the machine would be a node in your flowchart's graph.
Tetsujin no Oni