9.1 Concept of a Lifecycle


Each instance of a class generally has a lifetime. Objects are created, they progress through certain stages, and then go away. Their behavior is a progression through various stages over time. These changes over time are known as the lifecycle of the object.

As an example of a lifecycle, let's consider a light bulb. When power is applied, the bulb (if properly installed) goes on. When power is removed, the bulb goes off. Eventually the filament breaks and applying power has no effect.

Figure 9.1 shows a representation of the light bulb's behavior.

Figure 9.1. Lifecycle of Light Bulb

graphics/09fig01.gif

This simple pattern of dynamic behavior is followed by all light bulbs throughout their lifetimes.

Figure 9.1 shows how we've abstracted the behavior pattern into a collection of stages (on, off, and broken) and a collection of incidents (power applied, power removed, and filament breaks) that cause progressions from stage to stage.

In this chapter, we show how to use state machines to model lifecycles.[1]

[1] Some of this material is drawn from Object Lifecycles. [1]



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