I read a lot about it, but still not sure in what order states executes (in Composite States) and how exactly deep and shallow history works? Could anybody help me? I have an example, which I'm not sure how to solve, here it is:
I would appreciate any help!
Question 1:
... not sure .. how exactly deep and shallow history works?
Answer 1:
Note this:
A shallow history is indicated by a small circle containing an "H". It applies to the state region that directly encloses it.
Shallow history pseudostate represents the most recent active substate of its containing state (but not the substates of that substate). ...
Source: http://www.uml-diagrams.org/state-machine-diagrams.html#shallow-history-pseudostate
Question 2:
... I'm not sure if I always should start from initial point, which is outside of all composites?
Answer 2:
Yes. You start from the Initial Pseudostate of the root state (A in this case).
Example:
For the given state-chart and event chain, you would get the following result (simulated with Rhapsody):
after default transition to A
x = 3
x = x * 2 = 6
after default transition to A::B
x = 6
after e1
x = x + 1 = 7
after default transition to A::C::G
x = x + 1 = 8
after e3
x = x - 2 = 6
x = x / 2 = 3
after e4
x = x + 1 = 4
after e6
x = x - 2 = 2
x = x - 1 = 1
x = x - 1 = 0
x = (x * 4) + 2 = 2
after e7
x = x + 1 = 3
x = x + 1 = 4
e4 is discarded