Skip Navigation Links > Modeling > UML > State

State-machine diagram


Objects are characterized by behavior, state and identity. The state of an object depends on its current activity or condition. A state machine diagram shows the possible states of the object and the transitions that cause a change in state.

Our example diagram models the login part of an online banking system. Logging in consists of entering a valid secret security number (SSN) and personal id number (PIN) then submitting the information for validation.

Logging in can be factored into four possible non-overlapping states: Getting SSN, Getting PIN, Validating, and Rejecting. For each state a set of transitions determine the subsequent state.

State diagram

States are rounded rectangles. Transitions are arrows from one state to another. Events or conditions that trigger transitions are written beside the arrows. Our diagram has two self-transitions: Getting SSN and Getting PIN.

The initial state is a black circle. Final states terminate on black circles with an outer ring.

The action that occurs as a result of an event or condition is expressed in the form /action. While in its Validating state, the object does not wait for an outside event to trigger a transition. Instead, it performs an activity. The result of that activity determines its subsequent state.

States in state machine diagrams can be nested. Related states can be grouped together into a single composite state. Nesting states inside others is necessary when an activity involves concurrent sub-activities.

The following state machine models an auction with two concurrent sub-states: processing the bid and authorizing the payment limit.

State diagram with concurrent substates

Entering the Auction requires a fork at the start into two separate start threads. Each sub-state has an exit state to mark the end of the thread. Unless there is an abnormal exit (Canceled or Rejected), the exit from the composite state occurs when both sub-states have exited.


Self test

Top-of-page | Use-Case | Class | Package | Sequence | Communication | State | Activity | Deployment