Skip to content

UML State Diagrams

Estimated time to read: 2 minutes

Overview

A UML State Diagram is a technique that you can use the describe how your system behaves and responds. It follows the states of a system or object, and shows changes between the states as events occur. When an event occurs, you note how the system acts or behaves.

State Diagrams

A state diagram can describe a single object and illustrates object behaviour by depicting the changing states of an object.

State

A state is a the way an object exists at a particular point in time. The state of an object is determined by the values of its attributes.

UML State Diagram Elements

Starting State

A filled circle is drawn, this shows the starting state.

State States

States are listed in a rounding rectangle. States contain three sections of information.

Section Description Example
State Name This should be a meaningful name for the states of the object. Ring Bell
State Variables Data relevant to the state of the object. Time
Activities Actions that are performed when in a certain state. There are three types of activity. Entry Do Exit entry/ unlock spring do/ ring bell exit/ lock spring

State Activities in Detail

Entry Activities

Entry Activities are actions that occur when the state is entered from another state

Do Activities

Do Activities are actions that occur once, or multiple times, whilst the object is in a certain state.

Exit Activities

Exit Activities are actions that occur when the state is exited and moves on to another state.

Transitions

In State Diagrams, a solid line with a solid arrow head is used to represent events transitioning from one state to another. Transitions also have a line of text, which includes an event, a possible guard condition, and an action.

event [condition] / action
-------------------------->

Loops

Transitions can also loop within a state, these are shown by using a solid circular line and a solid arrow head. These usually include condition elements until the variable returns true.

Example

Screenshot 2022-07-15 at 10.29.24.png

Termination

Termination represents an object being destroyed, or the process being completed. It is drawn as a circle, with a filled circle inside.