A state machine diagram is used to model the dynamic behavior of individual class objects, use cases, and entire systems. In other words, when a state machine created where the object it is attached to, that object becomes the owner of the state machine, for example, the object to be attached by the state machine could be a class, use case or even the entire system.
A state machine diagram is a behavior that specifies the sequences of states an object goes through during its lifetime in response to events. A state machine are used to specify the behavior of objects that must respond to asynchronous stimulus or whose current behavior depends on their past. A state machines are used to model the behavior of objects, use cases, or even entire systems, especially reactive systems, which must respond to signals from actors outside the system.
In UML, state machines introduce the two new concepts in additional to traditional start chart notation:
Graphically, a state is rendered as a rectangle with rounded corners. A transition is rendered as a solid directed line.
Finding an online State Machine Diagram tool? Just click the Draw button below to create your State Machine Diagram online. Visual Paradigm Online is free* and intuitive. You can also go through this State Machine Diagram tutorial to learn about State Machine Diagram before you get started.
Draw NowA state is a condition during the life of an object which it may either satisfy some condition for performing some activities, or waiting for some events to be received.
A state has five parts:
An object remains in a state for a finite amount of time. For example, a Heater in a home might be in any of four states: Idle, Cooling, Heating, Initiating and Active.
Source State: The state affected by the transition; if an object is in the source state, an outgoing transition may fire when the object receives the trigger event of the transition and if the guard condition, if any, is satisfied.
Target State: The state that is active after the completion of the transition.
Event is a discrete signal that happens at a point in time. It also known as a stimulus and in a kind of input to an object. Here is the characteristics of events:
Action is executed as a result of instantaneously of state transition. State transition label can be expressed as the following format
A Decision ode is used to represent a test condition to ensure that the control flow or object flow only goes down one path.
Fork node is a pseudo state used to split an incoming transition into two or more transitions terminating on orthogonal target vertices. The segments outgoing from a fork vertex must not have guards or triggers and it must have exactly one incoming and at least two outgoing transitions.
Join node is a pseudo state used to merge several transitions emanating from source vertices in different orthogonal regions. The transitions entering a join vertex cannot have guards or triggers and it must have at least two incoming transitions and exactly one outgoing transition.
Merge node is used to bring back together different decision paths that ware created using a decision node.
Choice is a pseudo state which, when reached, result in the dynamic evaluation of the guards of the triggers of its outgoing transitions. This realizes a dynamic conditional branch. It allows splitting of transitions into multiple outgoing paths such that the decision on which path to take.
Example: Choice Node for State Machine Diagram
Terminate is a pseudo state indicates that the lifeline of the state machine has ended. A terminate pseudo-state is represented by a cross.
Unlike a final state, a terminate pseudo state implies that the state machine is ended due to the context object is terminated. There is no exit of any states nor does the state machine perform any exit actions other than the actions associated with the transition that leads to the terminate state.
A simple state is one which has no substructure. Composite States can be further broken down into substates (either within the state or in a separate diagram). A state which has substates (nested states) is called a composite state.
Besides composite state, there is another symbol called submachine state, which is semantically equivalent to a composite state.
A composite state with two or more regions is called orthogonal. Unlike composite states, submachine states are intended to group states, so you can reuse them. Orthogonal state is divided into two or more regions separated by a dashed line:
Note That:
You can use parallel and synchronized node to ordinate different substates. Concurrent Substates are independent and can complete at different time.
History states allow the state machine to reenter the last substate that was active prior to leaving the composite state. An example of history state usage is presented in the figure below:
You can use state machines in the following situations:
A Use Case model can be developed by following the steps below.
You can also:
The Digital Clock State Machine diagram example below shows the interface of a simple digital clock:
The state machine diagram where the class it is attached:
The state Diagram for modeling the behavior of the DigitalClock:
Some more State Machine Diagram examples are provided below.
State Machine Diagram example: Toaster
State Machine Diagram example: Oven
State Machine Diagram example: Computer Testing
This example represents two sets of concurrent substates by using two regions.
State Machine Diagram example: Human Life
This example represents two sets of concurrent substates by using two regions.
You've learned what a State Machine Diagram is and how to draw a State Machine Diagram step-by-step. It's time to get your hands dirty by drawing a State Machine Diagram of your own. Draw UML diagrams free* with Visual Paradigm Online. It's easy-to-use, intuitive.
Draw Now* The Free edition supports free usage of Visual Paradigm Online for non-commercial use only.