Andrea Sindico
Andrea Sindico

Reputation: 7440

UML State Machine ShallowHistory

I'd like to know whether I have correctly understood the ShallowHistory syntax or not.

Is this the right way to use it?

enter image description here

In the UML spec. it is said it can be used instead of the initial psuedo-state. I guess that in that case there would be no way to reset the State1's memory while in this case the transition from State0 always starts from State1.1. Am I right?

Upvotes: 4

Views: 2197

Answers (1)

vainolo
vainolo

Reputation: 6987

Your interpretation seems correct. From the Superstructure:

Upon entering a composite state, the following cases are differentiated:

• Default entry: Graphically, this is indicated by an incoming transition that terminates on the outside edge of the composite state. In this case, the default entry rule is applied (see Semantic variation point (default entry rule)).

And

Semantic variation point (default entry rule)

If a transition terminates on an enclosing state and the enclosed regions do not have an initial pseudostate, the interpretation of this situation is a semantic variation point. In some interpretations, this is considered an ill-formed model. That is, in those cases the initial pseudostate is mandatory. An alternative interpretation allows this situation and it means that, when such a transition is taken, the state machine stays in the composite state, without entering any of the regions or their substates.

And finally:

Shallow history entry: If the transition terminates on a shallow history pseudostate, the active substate becomes the most recently active substate prior to this entry, unless the most recently active substate is the final state or if this is the first entry into this state. In the latter two cases, the default history state is entered. This is the substate that is target of the transition originating from the history pseudostate. (If no such transition is specified, the situation is ill-defined and its handling is not defined.) If the active substate determined by history is a composite state, then it proceeds with its default entry.

Note that from the last paragraph, it seems you should ALWAYS have a transition from the H pseudostate, at least to the same state pointed by the initial pseudostate, otherwise you may have an ill-defined machine.

I didn't find where it says that you can use H* instead of the initial pseudo-state. Where did you see this?

Upvotes: 1

Related Questions