I have to implement a flow diagram structure in C#. I will pass in data to the first node, it will check some data item (boolean) then route the data on to one of two subsequent nodes and so on.
The basic logic flow is like this:
node 1
- If colour red goto node 2
- else goto node 3
node 2
- if weight 10 then goto node 4
- else goto rule 5
node 3
- if size big then goto node 6
- else goto node 10
etc
I have been looking at the Chain of Responsibility pattern which initially seemed to solve my problem. However, in most of my nodes (Handlers) I will need to have 2 subsequent nodes (true path and false path) to potentially call.
Looking at implementations of the CoR pattern, it seems that there is a concept of NextHandler (Next Node), but not NextHandlerA and NextHandlerB - for example.
So if not CoR which pattern would be better suited to solve this problem. The rules and the sequence may change frequently.
Thanks for your time.