In short
Based on the UML 2.5 specifications, this kind of diagram is perfectly valid. Nevertheless, by deduction, we can understand that it is not the best approach.
The details : why it is valid
According to the definitions (section 14.2.3.4.1
):
State1
is a composite state made of exactly one region.
State2
and State3
are simple states, and in this case they are also direct substates of State1
A first answer to your question is suggested by the rules on entering a state (section 14.2.3.4.5
):
Explicit entry: If the incoming Transition or its continuations
terminate on a directly contained substate of the composite State,
then that substate becomes active and ...
This is also reinforced in the rules related to regions (section 14.2.3.2
), and more precisely to their activation:
So your diagram is perfectly valid, with an explicit transition from initial state to the substate State2
.
The details: why it is not recommended
First of all, it is suggested (section 14.2.4.5.1) that it may help in some case to hide the decomposition of a composite state:
- With explicit activation, such hiding would require to draw a variation of the model, showing a transition from initial to
State1
instead of the direct transition to State2
.
- With default activation, you'd have only one model: initial to State1 and State1::initial to State2. Up to you to show or hide the details. Or to zoom into the region ignoring its context.
Then, if you'd later need to extend your composite state with multiple "orthogonal" regions:
- with default activation, you'd just add additional regions with their own default activation.
- with explicit activation, you'd have an asymmetry between one (explicitly activated) region, and the other regions (that require default activation).
- alternatively, you could consider having multiple explicit activations. But this is not well supported: first there is no transition with multiple targets, second, multiple transitions from the (external) source state to the different (internal) target substates, would be ambiguous in regard of the semantics and execution model of transitions.
The UML specs warn that if default activations are missing, one should consider the model as ill-defined, or that the region will never start. So it's safer to use a systematic approach, and always use default activation.