Explain state chart diagram

A state chart diagram is normally used to model how the state of an object changes in its lifetime. State chart diagrams are good at describing how the behavior of an object changes across several use case executions. However, if we are interested in modeling some behavior that involves several objects collaborating with each other, state chart diagram is not appropriate. State chart diagrams are based on the finite state machine (FSM) formalism A FSM consists of a finite number of states corresponding to those of the object being modeled. The object undergoes state changes when specific events occur. The FSM formalism existed long before the object-oriented technology and has been used for a wide variety of applications. Apart from modeling, it has even been used in theoretical computer science as a generator for regular languages. A major disadvantage of the FSM formalism is the state explosion problem.

The number of states becomes too many and the model too complex when used to model practical systems. This problem is overcome in UML by using state charts. A state chart is a hierarchical model of a system and introduces the concept of a composite state (also called nested state). The basic elements of the state chart diagram are as follows:

  •  Initial state- This is represented as a filled circle
  •  Final state- This is represented by a filled circle inside a larger circle.
  • State- These are represented by rectangles with rounded corners.
  •  Transition- A transition is shown as an arrow between two states. Normally, the name of the event which causes the transition is places alongside the arrow. A guard to the transition can also be assigned. A guard is a Boolean logic condition. The transition can take place only if the grade evaluates to true. The syntax for the label of the transition is shown in 3 parts: event [guard]/action.

Leave a Reply