State Machine Diagram Tutorial

What is a state diagram in UML?

A state diagram, sometimes knowns as a state machine diagram, is a type of behavioral diagram in the Unified Modeling Language (UML). It specializes in showing transitions between various objects.

You can build state diagrams, and many other types of UML diagrams, with Lucidchart’s premier chart-making technology. Never has diagramming been more simple or affordable.

Demo here
Sign up free

What is a State Diagram in UML?

A state machine is anything that can have different states. In many cases when we are talking about states, we are talking about the different states of an object. Complex diagrams can have many different states. In order to better understand difficult objects, it sometimes makes sense to make out all the different possible states of an object and how an object gets to that state. The states are the different combinations of information that an object can hold and not how they behave.

Each state diagram typically begins with a dark circle that indicates the initial state and ends with a bordered circle that denotes the final state. However, despite having clear start and end points, it should be remembered that state diagrams are not necessarily the best tool for capturing an overall progression of events. Rather, they specialize in illustrating specific kinds of behavior—in particular, shifts from one state to another.

The main elements that state diagrams depict are states and transitions. States are captured by rectangles with rounded corners that are labeled with the name of the the state. Transitions are marked with arrows that flow from one state to another, showing how the states change. Below, you can see both these elements at work in a basic diagram for student life. Our UML tool can help you design any custom state machine diagram.

state

State Diagram Applications

Like most UML diagrams, state diagrams have several different uses. The main applications are as follows:

  • Depicting event-driven objects in a reactive system.
  • Illustrating use case scenarios in a business context.
  • Describing how an object moves through various states within its lifetime.
  • Showing the overall behavior of a state machine or the behavior of a related set of state machines.

State Diagram Components

Many different shapes can be included in a state diagram, particularly if you choose to combine it with another diagram. This list is a summary of the most common shapes you may encounter:

  • Composite state - a state that has substates nested into it.
  • Choice pseudostate - a diamond symbol that indicates a dynamic condition with branched potential results.
  • Exit point - the point at which a composite state or state machine is exited, denoted by a circle with an X through it.
  • Event - an instance that triggers a transition, labeled by name above the applicable transition arrow.
  • Final state - a marker for the first state in the process, shown by a dark circle with a transition arrow.
  • Guard - a Boolean condition that allows or stops a transition, written above the transition arrow.
  • State - a rectangle with rounded corners that indicates the current nature of an object.
  • Substate - a state contained within a composite state's region.
  • Transition - an arrow running from one state to another that indicates a changing state.
  • Transitional behavior - a kind of resulting behavior that happens as a state transitions, written above the transition arrow.
  • Trigger - a type of message that actively moves an object from state to state, written above the transition arrow.
What is a state diagram in UML?

State Diagram Example

In this state machine diagram, we are showing the different states of the calendar object from the sequence diagram example where we show the flow of someone setting an event in a calendar.

state diagram

State Diagram Symbols and Notation

end state diagram UML - The circle with a dot in it means that a process is terminated.

flow final state diagram - The circle with an "X" in it means that a process is being escaped.

state- The state boxes represent the different states that a machine can be in during a process.

start - A solid black dot represents the start of a process.


State Machine Diagram Resources

Use Lucidchart to collaborate and create UML diagrams when you start an account for free today! No plugins or download required.

Sign up