UML State Machine Diagram Tutorial
State Machine Diagram in UMLA 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 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
- Composite State
- Signal Receipt
- Signal Send
- Protocol Transition
- Entry Point
- Exit Point
- Deep history
- Shallow History
- Terminate Node
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.