Explain why and how the statechart diagram is used during design
Statechart Diagram
In most systems, there are at least a few key classes of objects that undergo substantial changes during their lifetime. For these objects, a single event may result in very different responses based on the current condition of the object. The condition of the object is referred to as the object's state.
Object state
The state is defined by the values of the attributes and the relationships of the object. For example, when a credit account is open, an attempt to purchase an item will result in a comparison of the purchase amount and the available credit. When the credit account is closed, an attempt to purchase items results in an error. Likewise, a relationship may cause a different response.
For example, when a ShowSeat in the ticketing system is not associated with a PriceTier, it cannot be sold.
Once the link to the PriceTier has been established, the ShowSeat may be sold.
When to use statechart
The statechart will not be used for every class in the model. The statechart is a special purpose tool that is employed only for objects that possess substantial state-specific behavior. How can you recognize such objects? One technique is to review the interaction diagrams and identify those objects that participate in most, or even all, of the scenarios. Specifically, look for those objects that have the most incoming event arrows because every incoming event has the potential to change the current state of the object.