Because statechart diagrams are visually intuitive, they’re great for capturing business rules in a way that your stakeholders can understand. Statechart diagrams show the valid states that a business entity can take, and the events that make the entity change state.
Suppose you are defining requirements for the order management system of a business that sells customized products. Consider the business rules and workflow for a custom order. The order has to be tracked through the process of taking, planning, fulfilling and delivering it.
To create a statechart diagram (also known as a state diagram or state-transition diagram), think about the different states that an order can take. Each state is a distinct status and is drawn as a rectangle with rounded corners.
Show the valid ways the order can move from one state to another by connecting the states with transitions. The diagram begins with a start state (a filled small circle) and ends with a stop state (a small filled circle within a larger concentric ring). Transitions between states are triggered by events. You can label each transition with the event that caused it to happen. For example, when an order is placed, the order enters the New state (until something else happens).
The statechart diagram will help ensure you and your stakeholders have the same understanding of the business rules. You’ll also discover new business rules by walking through the diagram. For example, can an order be canceled once it is in progress? There’s probably a business rule that determines if and when that can happen.
Consider a business rule that states an in progress order can only be cancelled with a manager’s approval. We can add that to our statechart diagram using a guard condition. Guard conditions are like gates that only open under certain conditions. Use a bit of text to state the condition that has to be true in order to follow a transition (e.g. “Manager Approval”).
As you are developing requirements, you’ll likely discover new states, or realize that other states aren’t valid. Keep your states at a level that is of interest to your business stakeholders. It’s not necessary to capture every possible state – just the ones that are meaningful in the scope of your requirements.
Getting stakeholders to actually read requirements is always a challenge. Put six important paragraphs of requirements next to a diagram and guess what your readers will study. The diagram, of course – everybody likes pictures. Without any training, a business stakeholder can look at a statechart diagram, understand it, and point out where it falls short. This makes the statechart diagram a valuable tool for getting you and your readers on the same page with regard to business rules.