I l@ve RuBoard |
9.1 Concept of a LifecycleEach 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 BulbThis 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]
|
I l@ve RuBoard |
No comments:
Post a Comment