Our first state machine was relatively simple, but it did represent the basic design for conventional state machines. Sometimes, however, this straightforward approach can be difficult to manage. Imagine if the workflow for our bug-tracking software required us to allow a user to close or assign a bug — regardless of the current state of the bug. We'd have to add event-driven activities for the assigned and closed events to every state in the workflow (except the completed state). This might be fine when we only have a handful of states, but can become tedious and error prone as the state machine grows.
Fortunately, there is an easier solution. A hierarchical state machine allows us to nest child states inside parent states. The child states essentially inherit the events driven activities of their parent. If every state in our bug tracking workflow needs to handle the bug-closed event with the same behavior, we only need to add one event-driven activity to a...