9.4 Creating and Deleting Objects


Many classes have instances that are created and deleted over time. We can model creation and deletion of objects in the state machines.

9.4.1 Initial Pseudostates

The semantics of UML state machine instance-creation are as follows: First, an object is created, then the state machine instance is started, then the state machine instance is ready to receive events. The state machine instance is started in its initial pseudostate.

Definition: An initial pseudostate is the state in which the state machine instance for an object is started.

An initial pseudostate is shown by a filled-in circle, as in Figure 9.10.

Several transitions may emanate from the initial pseudostate, so long as each is caused by a different event, just as with any other state.

9.4.2 Final Pseudostates

A state machine instance and its corresponding object are implicitly deleted when a state machine instance makes a transition to a final pseudostate.

Definition: A final pseudostate is the state in which an object is deleted.

Final pseudostates are indicated on the statechart diagram by a bulls-eye symbol. The unlabeled transition to the final pseudostate is a completion event. As soon as the final state's procedure completes, the instance transitions to the final pseudostate and goes away.

In addition, state machines may have one or more states in which they become quiescent. In a quiescent state, the object continues to exist, but has no subsequent interesting dynamic behavior. While no special notation is used on the statechart diagram, such final states can be identified by their lack of outbound transitions.

The action language that we use in this book has a single statement


generate <signalto <classcreator;

that actually incorporates three individual actions:

  • create object

  • start state machine instance

  • send signal

See Section 10.2: Creating and Deleting Objects for examples.

Examples of each construct are shown in Figure 9.10.

Note that part of abstraction is distinguishing between application behavior and computer behavior. For example, in many financial systems accounts never really go away. Instead they are archived for posterity (or the IRS).



Executable UML. A Foundation for Model-Driven Architecture
Executable UML: A Foundation for Model-Driven Architecture
ISBN: 0201748045
EAN: 2147483647
Year: 2001
Pages: 161

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