umlstatesta

What does 'do' do in an UML Statechart diagram?


I am not 100% sure what 'do' does in an UML statechart diagram.

Is my thinking correct:

If a transition happens, 'entry' will be executed first and then 'do' will be executed. And if we are leaving the state only 'exit' will be executed.

Does this logic apply to reflexive transitions as well?

And what if a trigger happens, that does not set off a transition? Does this only execute 'do'?


Solution

  • The UML Specification tells us:

    14.2.3.4.3 State entry, exit, and doActivity Behaviors

    . . .

    A State may also have an associated doActivity Behavior. This Behavior commences execution when the State is entered (but only after the State entry Behavior has completed) and executes concurrently with any other Behaviors that may be associated with the State, until:

    • it completes (in which case a completion event is generated) or
    • the State is exited, in which case execution of the doActivity Behavior is aborted.

    The execution of a doActivity Behavior of a State is not affected by the firing of an internal transition of that State.

    You :

    Does this logic apply to reflexive transitions as well?

    As said by the last sentence above that depends if the reflexive transition is internal or external.