State machine diagram represents the life-cycle of object so, What is the corresponding of it(state machine as local view of object) in programming level?
Asked
Active
Viewed 125 times
1 Answers
2
There is no direct correspondence between a state machine and code, you could use any programming algorithm to implement it. For example, you could use an enumeration type with an enumeration literal for each possible state and use it in your implementation class to represent to current state of your instance.
But you could also use other values like "if the user has an empty command list he is in the prospect state".

Xaelis
- 1,609
- 10
- 17
-
thank you @Xaelis . what about events and effects in the transition signature?? – Chriss Jul 30 '13 at 15:23
-
1There is also many ways to translate them in code. Events can be method calls or a "real" events is you are using the observer pattern. Behaviors (effects) are often implemented in a method. – Xaelis Jul 30 '13 at 15:35