A state diagram, or state machine diagram, shows the states an object moves through over its life and the events that trigger each transition. This template is a worked example, an order's lifecycle, running from Draft through Pending payment, Paid, Shipped, and Delivered, with Cancelled reachable along the way. Developers and analysts use it to model how something behaves as events change its state.
Both are UML behavior diagrams, but they model different things. A state diagram tracks one object through its states and the events that move it between them: the order is Draft, then Paid, then Shipped. An activity diagram models a process as a flow of actions and decisions, often across actors, closer to a flowchart. Use a state diagram when something has distinct states and rules for changing them; use an activity diagram to map how work flows from step to step.
A state diagram, also called a state machine diagram, is a UML diagram that shows the states an object can be in and how it moves between them. Each state is a stage in the object's life; each transition is an arrow triggered by an event. It models behavior over time, answering what state something is in and what event moves it to the next one.
A state is a rounded rectangle with its name inside. A filled circle is the initial state, and a filled circle inside a ring is the final state. A solid arrow is a transition, labeled with the event that triggers it and any guard condition. A diamond is a choice point with one transition in and several out. Together these capture every state and the rules for changing it.
A state diagram tracks one object through its states and the events that move it between them: an order is Draft, then Paid, then Shipped. An activity diagram models a process as a flow of actions and decisions, often across actors, closer to a flowchart. Use a state diagram when something has distinct states and rules for changing them; use an activity diagram to map how work flows step by step.
List the states the object can be in, then add an initial node pointing to the first one. Connect states with arrows in the direction change happens, and label each arrow with the event that triggers it. Add the exits for cancellation, failure, and other off-path routes, and close the lifecycle at a final node. The result is a complete map of how the object behaves.
This template's board is one: an order's lifecycle. It starts at Draft, moves to Pending payment on submit, then to Paid on payment confirmed (or back on payment failed), then Shipped on dispatch and Delivered on delivery. Cancelled is reachable from several states, with a refund transition. A door (open, closed, locked) or a traffic light are other classic examples.