5 Steps To Draw A State Machine Diagram
5 Steps To Draw A State Machine Diagram
In order for others to understand them more easily, abstraction also takes place for simplicity reason in the modeling
process. So it is important to note that a state machine diagram does not necessarily model all possible states, but
rather the critical ones only. When we say critical states, we mean those that act as stimuli and prompt for
response in the external world.
Take our bank account example above. As far as the behavior goes, there really isnt significant difference when the
balance is $1,000 or $1,001. However, the state becomes much more meaningful when the balance hits zero.
2. In the New Diagram window, select State Machine Diagram and click Next.
Page 1 of 11
Tutorial 5 Steps to Draw a State Machine Diagram
3. Enter Bank Account as diagram name and click OK to create the diagram.
The new diagram appears with an initial state (a solid black circle) by default.
4. Drag State from the toolbar onto the diagram. Name it account with funds.
5. Again, drag State from the toolbar onto the diagram. Name it zero balance.
Page 2 of 11
Tutorial 5 Steps to Draw a State Machine Diagram
2. Drag the title bar of Description pane and move it next to the state account with funds. Select account with
funds and enter the description: When the balance of the bank account exceeds $0.
3. Select the zero balance state. Enter its description: When the balance of the bank account hits $0.
2. Press on the Resource Catalog button that appears above the shape. Drag to the state account with funds.
Page 3 of 11
Tutorial 5 Steps to Draw a State Machine Diagram
3. Release the mouse button over account with funds. A transition will be created.
4. Similarly, create a transition from the state account with funds to zero balance. This time, move your
mouse pointer over account with funds, then press on and drag the Resource Catalog button and release
your mouse on the state zero balance.
5. Apply the same technique to create a transition from state zero balance to account with funds.
After drawing it, press on the transition connector and drag to the left to make a cup handle shape as shown
below.
6. Create the final state. This time, move your mouse pointer over the state zero balance. Then, press on the
Resource Catalog button and drag to the empty region below the state.
Page 4 of 11
Tutorial 5 Steps to Draw a State Machine Diagram
7. Release the mouse button. In the popup pane, select Transit -> Final State.
8. Click a self-transition on the state account with funds. Move your mouse pointer over the state account with
funds and click on the Resource Catalog button.
Page 5 of 11
Tutorial 5 Steps to Draw a State Machine Diagram
11. Add another self-transition on account with funds. Rearrange the line as needed. After drawing all
transitions, you should end up with a similar diagram as shown below.
1. Right click on the transition that connects the initial state and account with funds and select Open
Specification from the popup menu.
Page 6 of 11
Tutorial 5 Steps to Draw a State Machine Diagram
3. Click Add and then select Call Trigger from the popup menu.
4. In the Call Trigger Specification, enter open bank account as name and click OK.
5. Click OK again in the Transition Specification to return to the diagram. You should see the trigger name
appear as the caption transition.
Page 7 of 11
Tutorial 5 Steps to Draw a State Machine Diagram
1. Right-click on the self-transition withdraw funds and select Open Specification from the popup menu.
2. In the General tab of the Transition Specification, enter balance > 0 as Guard and click OK to confirm.
Page 8 of 11
Tutorial 5 Steps to Draw a State Machine Diagram
You can see the transition caption updated with guard presented.
3. Apply the same technique to add the balance == 0 as guard condition of that connects the state account
with funds and zero balance as shown.
Page 9 of 11
Tutorial 5 Steps to Draw a State Machine Diagram
Page 10 of 11
Tutorial 5 Steps to Draw a State Machine Diagram
Page 11 of 11