State machine diagrams captures the life cycles of objects, sub-systems and systems. They
indicate what states an object can have and how different events affect those states over time.
State machine diagrams should be attached to classes that have clearly identifiable states and is
governed by complex behaviour.
A State is displayed as a rounded rectangle with optional compartments for attributes, events and
internal activities. State flows or transitions are drawn between States, usually with guard
conditions and rules governing how and when an object may transition from one state to another.
States are usually named according to their condition, for example 'Checking', 'Waiting' and
'Dispatching' are all active conditions an object can be in while waiting to transition to another state
or end the cycle completely.
Start and end nodes represented as solid and empty circles are used to represent the beginning
and end of all transitions. State machine diagrams can have a start point and several end points.
State transitions may be triggered by events. These events may have keywords (guards)
associated with it to clarify the event. It is not always necessary to show these events.
States can be nested. This implies that states (sub states) can exist in an overall state. Parallel
states can also be defined where an object may have several states at the same time. For
example: A person has at any time many parallel states. These may be: walking, thinking, young,
etc.
Consider the following state chart of an invoice class: