Designing statecharts

Statecharts define the behavior of objects by specifying how they react to events or operations. The reaction can be to perform a transition between states and possibly to execute some actions. When running in animation mode, IBM® Rational® Rhapsody® highlights the transitions between states.

Statecharts define the run-time behavior of instances of a class. A state in a statechart is an abstraction of the mode in which the object finds itself. A message triggers a transition from one state to another. A message can be either an event or a triggered operation. An object can receive both kinds of messages when sent from other objects. An object can always receive events it sends to itself (self-messages). In Rational Rhapsody, statecharts are part of the object-oriented paradigm. The more complicated classes can have statecharts; simpler classes do not require them.

You can use operations and attributes in classes with statecharts to define guards and actions, as in the following example.

Statechart with guards and actions

Feedback