shield_person
TankMentor
UMLMarch 2, 2025

State Transition Diagram

State Transition Diagram

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:

image.png

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. Sample

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

8d8890_f5f10fba4c944c1482b9ae75ae4ec651~mv2.png

Example 2: Object with multiple types of states - Order

There are 3 status:

  • Order status
  • Payment status
  • Shipping status

8d8890_165172e99e174cd7870900e236447633~mv2.png

Order status

8d8890_d7e44f783d7849539326c23fbf244ae5~mv2.png

Payment status

8d8890_cfef0ee916bd476aab32f1622bc598f8~mv2.png

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

TM

TankMentor Executive

Strategic BA & PM Consultant