umlstatediagramstaruml

Is a state without a direct transition allowed in UML state diagram?


Is a state without a direct transition allowed in UML state diagram (SD) like the below drawn with StarUML?

State1 is not directly involved in any transition so I'm in doubt wether this is allowed in UML / desirable. I think in my application I'm actually modeling multiple objects in a single SD.

enter image description here


Solution

  • 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):

    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:

    Then, if you'd later need to extend your composite state with multiple "orthogonal" regions:

    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.