What is a state diagram?
A state diagram is the graphical representation of a state machine and one of the 14 UML diagram types for software and systems. State diagrams show a behavioural model consisting of states, state transitions and actions. UML state diagrams are based on the concept of state diagrams by David Harel. State diagrams depict the permitted states and transitions as well as the events that effect these transitions.
What are state diagrams for?
State diagrams are commonly used in the area of embedded systems. State diagrams help to visualize the entire life cycle of objects and thus help to provide a better understanding of state-based systems. An example of such a state-based system is a cash machine: Upon activation either the state ready or the state malfunction could be reached. As soon as the debit card is inserted it is verified. Depending on the result of the verification the pin number is requested or the process is aborted. Other possible states are account query or availablility check etc.
Create a state diagram fast and
effortlessly with tool.
Test our Enterprise Software objectiF RPM. Free Trial.
State diagrams depict the different states of a state machine.
They also depict the events effected by state transitions.
Why are state diagrams important?
State diagrams are irreplaceable when describing systems and system behaviour, for example electronic components such as control units for driver assistance systems in vehicles. For these systems permitted states are defined and visualized in state diagrams, as well as activities which are carried out in specific states or during the course of transitions.
ESP (electronic stability program) effects an intervention into the vehicle guidance if sensors transmit values (e.g. revolution speed, yaw rate) that deviate from specified values. The result is a state change of affected components such as vehicle brakes.
The benefits of state diagrams
State diagrams are the ideal way to model object life cycles. State diagrams enable you to describe the behaviour of objects during their entire life span. In addition, the different states and state changes as well as events causing transitions can be described. On other words: State diagrams make the system behaviour visible.
States
To be able to model objects as state diagrams the state must fulfill specific requirements:
- The object depicted is in exactly one of the permitted states. In other words:
- The object depicted is never in none of the permitted states.
- The object depicted is never in multiple states at the same time.
States in state diagrams are modelled as rounded rectangles. These rectangles may also include a name and can be divided into up to three areas: name, state variables and internal events as well as conditions and resulting operations.
Events
For an event three possible behaviours exist:
- entry – is automatically effected upon entering a state
- exit – is automatically effected upon exiting a state
- do – is effected in case no state change is effected
Transitions
State transitions from one state to another are effected by events. Events consist of a name and assigned arguments. In some cases a specific state can only be effected by an event if certain conditions have been met.
Transitions establish a connection between a source node and a target node. The transition can be assigned a behavioural specification which describes the behaviour to be effected when passing through the transition. The behaviour effected is called effect. In addition, so-called guards “protect” the transition. Protected transitions can only be passsed-through if the guard is true.
There are two types of transitions:
- Internal transitions describe the reaction to an event that effects an activity, but no state transition. As a consequence, no entry or exit activities are executed.
- External transitions describe transitions that cause an object to enter or exit a state as a reaction to an event. During the course of the transition exit activites of the source state and extry activities of the target state are executed. A special type of transition is the self transition in which the source state and the target state are identical.
State diagrams show the states of an object
as well as the reasons for state changes.
Your state diagram is complete – what now?
When all states, events and transitions of your system or artefact have been defined the first step to successful systems development has been made. But this knowledge needs to be made available to your entire team. The way you process and work with this knowledge decides whether your project will be successful. The best way to make knowledge, information and project data availbale is a designated tool that lets you work together, collaboratively in your team, in real-time.