UML State Machine Diagram Tutorial

A state machine diagram describes states of en entity (device, process, program, software, module, etc.) and transitions between the states. Conditions specifies when a transition from a state to another state may be used.

State Machine Diagram in UML

A state machine diagram is a behavior UML diagram. It depicts the transitions between particular states. The initial state indicates the state that the modeled object starts in. The final state refers to the state where the activity of the modeled object ends.
State Machine Diagram in UML
State Machine Diagram in UML

State Machine Types

A state machine diagram may be one of two types:

  • Protocol state machine
  • Behavior state machine

The type of state machine diagram can be set using Diagram Properties dialog - State Machine tab.

State Machine Symbols

Software Ideas Modeler offers tools for following elements of a state machine diagram:

  • Initial Pseudostate
  • Final Pseudostate
  • State
  • Composite State
  • Fork
  • Join
  • Choice
  • Signal Receipt
  • Signal Send
  • Transition
  • Protocol Transition
  • Entry Point
  • Exit Point
  • Deep history
  • Shallow History
  • Terminate Node
  • Junction
  • Frame
Overview of State Machine Diagram Elements
Overview of State Machine Diagram Elements

What is a State?

A state represents a specific life span of an object defined by constraints. An object in a given state shows specific behavior. The reactions of an object to the same inputs may differ depending on the object state.

If an object is in a given state it fulfills the invariant condition. The invariant is usually implicit. You can also define the invariant condition explicitly. Then it is displayed in the brackets under the state name.

A state may define three activities that are performed depending on a state change.

  • Entry - if a state is changed to this state, the entry activity is performed.
  • Do - the behavior that is performed while the object is in this state.
  • Exit - if this state is left and it is changed to another state, the exit activity is performed.

How to Draw a State Machine Diagram?

You can create a new state machine diagram in multiple ways:

  • Click on a Plus button in the tab switch bar, navigate to UML group and click on the UML State Machine Diagram item
  • Press CTRL+SHIFT+D, choose State Machine Diagram from the UML group, enter the name and click on the OK button.
  • Switch to Project tab in the ribbon and click on the State Machine Diagram item in the Content gallery.
  • Open Project sidebar, right-click on a project (or a folder) node, and in the Add Diagram submenu, choose UML State Machine Diagram.
Create a new UML state machine diagram
Create a new UML state machine diagram

UML State Machine Diagram Examples


Greville Earle 4 August 2023 11:05:31

State actions

Hello. When I create Entry, Exit or Do actions for a state (i.e. in a state machine diagram) I do not see them appear anywhere in the model browser. Similarly, I am unable to select any existing actions that I may have already created to fulfil the Entry, Exit or Do behaviour of a state. Am I driving incorrectly ?

Thank you.

Dusan Rodina - 4 August 2023 22:26:35

RE: State actions


You are right, this option is currently missing. The state actions are handled only as simple fields. The model of the UML State element will be improved in the next version.

New Comment