So as I am a bit of electrician and programmer I thought I knew FSM design pattern very well. It is:
- We have set of
Nodes, - Each
Nodeknows, what to do, when program is in this node, - Each
Nodecontains references to another chosen nodes, and knows under what condition, should he proceed to the chosen one. - On
eventorafter processinga Node,Node proceedsto the next chosen Node
I thought, that it was quite clear to me. Although recently, when I was implementing a State Machine one person told me, that it is in fact a bit modified Chain of responsibility (not sure if he was correct) and , what I did/had was:
- Set of
Nodes(which did not represented a linear or tree structure) - Nodes had objects, that knew under which condition they should jump to which Node
- Each Node had it's own context of processing (some parts of contexts were shared between Nodes).
Unfortunatelly I am afraid, that due to legal issues I am not allowed to paste a class diagram here.
On the other hand we have got chain of responsibility, which I would (as I understand) define in a following way, that is:
- We have got some
ItemToProcessInterface, - We have got some
NodeInterface, - Node has a reference to only one next Node,
- Each Node processes
ItemToProcessand forwards processed one to thenextNode
So as far as I understand:
- We use
Chain Of Responsibility, where we want One item to be processed (or at least tried to be processed) by each node - Chain of responsibility represents sequential and constant execution of processes
- We use
StateMachineto represent graphs - We use
StateMachineto perform computations, which order or kinds of computations may vary depending on some events.
I would like to ask you to confirm my understanding of those design patterns or tell me where I am making mistake in understanding.


