top of page

State Transition Diagram

Writer: Tuan AnhTuan Anh

1. Definition

A State Transition Diagram (also known as a state machine diagram) is a visual representation of the different states an object can exist in, as well as how it transitions from one state to another based on events.


Example: Imagine a simple flashlight. It can be in one of two states: "On" or "Off." The event "Press button" will cause the flashlight to switch between these two states.


2. Notations

A State Transition Diagram typically includes the following components:

Name

Symbol

Meaning

State

Represents a state of the object.

Transition

Represents the transition between states and the condition (who - does what) that triggers the transition.

Start

The starting point (usually when the object is created).

End

The ending point (usually when a state cannot transition further).


3. When to Use State Diagrams


So, when should you use a state diagram?

  • When an object has multiple states, and these states change based on different events. For example, the status of a user account (active, inactive, locked), the status of an order (New, Processing, Delivering, Completed), etc.

  • When the business logic involves complex state changes. State Transition Diagrams help visualize different processing flows based on the current state and occurring events. For example, an order can have separate payment status, shipping status, and order status (see example in section 4).

  • When you need to communicate and exchange information about system behavior with stakeholders. The diagram facilitates communication between developers, business analysts, testers, and clients.

  • When designing test cases. State Transition Diagrams provide an overview of states and transitions, making it easier to design test cases that cover all possible scenarios.



4. Ví dụ

Note: The state of an object depends on the business rules of each company. Even within the same domain, different businesses may have different ways of applying those rules, leading to variations in the states of the same object type across different systems. For example, an order on Shopee will have different states compared to an order on Tiki. In the examples below, the order states are provided for illustrative purposes. In reality, you need to gather complete requirements before deciding on the states of an object.


Example 1: Object with one type of state - Leave request

State transition diagram example 01
State transition diagram example 01

Example 2: Object with multiple types of states - Order

There are 3 status:

  • Order status

  • Payment status

  • Shipping status


Order status



Payment status



Shipping status


By understanding and utilizing State Transition Diagrams, BAs can effectively model and communicate complex state-based behavior, leading to clearer requirements and better software design.

 
 

Comments


  • Facebook
  • LinkedIn

TankClass

bottom of page