Developing Statechart Diagrams (Design)


The Statechart diagram shows the sequence of object states a single class can exhibit during its lifetime, together with the events that cause the changes of state. This is in contrast to the Interaction diagrams, which show the interaction between multiple classes.

The classes of objects that a Statechart examines can be derived from UML diagrams, such as Use Case, Class, or Interaction diagrams. The intent is not to develop Statechart diagrams for every class in a system ”only those that show variable or complex behavior ( reactions ) to events dispatched from outside their context should be considered . For example, in the Model, View, Control (MVC) design pattern, it is the responsibility of the Control to react to events. For this reason, the behavior of the Control is a good candidate for a Statechart diagram.

Note

Statechart models are ideal for describing the behavior of a single class. Their biggest limitation is that they are not good at describing behavior that involves several classes. For such cases you can use an Interaction or an Activity diagram.


The Features of a Statechart diagram

A Statechart is typically comprised of the following elements:

  • A state belongs to a single class and represents a combination of possible attribute values that the objects of this class may assume during the life of the class. The UML notation for representing states is illustrated in Figure 3.8.

  • An event is the occurrence or stimuli that triggers a state transition. For example, an object receives a message. Events can also have arguments that are passed from state to state as well as actions , which are regarded as atomic operations that prematurely terminate.

  • A transition is a relationship between two states. It implies that when a change of state is caused by an event in the first state, the object will move to the second state. All events exist in the context of transitions, as illustrated in Figure 3.30.

    Figure 3.30. The UML representation of States, Events, and Transitions.

    graphics/03fig30.gif

Figure 3.31 illustrates an example Statechart diagram that has been derived from a Sequence diagram.

Figure 3.31. A Statechart diagram that has been derived from a Sequence diagram.

graphics/03fig31.gif



BEA WebLogic Platform 7
BEA WebLogic Platform 7
ISBN: 0789727129
EAN: 2147483647
Year: 2003
Pages: 360

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net