Updated April 8, 2023
Introduction to State Diagram
The state is a mode or condition of being. A state diagram is a dynamic model that shows the state changes that an object goes through during its lifetime in response to events. It is used to help the developer better understand any complex functionality of specialized areas of the system. A state diagram is also called as state chart diagrams, depict the dynamic behavior of the system in response to external and internal events.
How to Design State Diagram?
Given below shows how to design a state diagram:
1. Initial State
A filled circle denotes it. It shows the starting point or the first activity of the diagram. This state is also called a pseudo-state, where the state has no variables and no activities.
Symbol:
2. Final State
A filled circle with a border denotes it. It shows the end of the state diagram. This is also a pseudo-state because it does not have any variable or action described. A state diagram can have zero or more final state.
Symbol:
3. State
It represents the state of the object at an instant if time. The state is a recognizable situation and exists over an interval of time. A denoted rectangle and compartment denote this to describe state name, variable and activities.
Symbol:
4. Transition
Transition is a change from one state to other. An arrow denotes it. The event and action causing the transition are written beside the arrow, separated by a slash. A transition that occurs when the state completed activity is called a trigger less transition. If an event has no occur after the completion of some event or action, that event or action is called the guard condition, i.e. depicted by square brackets around the description id the event or action in the form of a Boolean expression. The transition then takes place after the guard condition occurs.
Symbol:
5. Event and Action
A trigger that causes a transition to occur and changes the state is called as an event or action. An event that occurs at a particular time has no duration. An event or action is written above the transition that it causes.
6. History State
Flow may require that the object go into a wait state and go back to the state it was in on the occurrence of a certain event. This is shown with the help of the letter H enclosed within a circle.
7. Signal
When an event causes a message or trigger to be sent to a state that causes the transition, then that message sent by the event is called as a signal. This is denoted by the << Signal>> icon above the action or event.
8. Self Transition
A state can have a transition that returns to itself, which is called s self transition. This is most useful when an effect is associated with the transition.
9. Action Inside State
Actions execute a function, assign a value to a data variable or initiate another transaction. Specify these internal actions one per line. These internal actions are processed without causing a state change. It takes the form: action-label or action- expression.
Action- the label can be any of the following:
- Entry: Executes the associated action-expression upon the state entry. For example, entry / count: = 0; sum: = 0.
- Exit: It executes the associated action expression upon the state exit. For example, exit/ring bell.
- Do: It executes the associated action expression upon the state entry and continues until state exit. For example, do/display flashing light.
- Include: This action expression must name finite automation. The named Automation is a placeholder for a nested state diagram. For example, include / Order processing.
Action-expression- description bod computation.
Uses of State Diagram
- A state diagram is used to design the dynamic aspect of the system.
- It defines the state of the components and state changes triggered by an event. Events are internal and external factors influencing the system.
- During system implementation, it is important to clarify the different states of the object during its lifetime. A state diagram is used for this purpose. When this state and even are triggered, they are used to model it, and these model are used during the system implementation.
- Mainly used to model the object states of the system.
- A state diagram is also used to identify events causing the changes in the state.
- Used to model reactive system.
- A state diagram is also used for forward and reverse engineering.
Example
Given below is the example of state diagram:
Here we will take an example of ATM and will draw a state diagram.
Recommended Articles
This is a guide to State Diagram. Here we discuss the introduction, how to design a state diagram? Uses and example, respectively. You may also have a look at the following articles to learn more –