Monday, October 26, 2009

9.6 Lifecycles for Classes




I l@ve RuBoard









9.6 Lifecycles for Classes


Recall the definition of a class.


A class is an abstraction of a set of real-world things such that



  • All the real-world things in the set�the instances�have the same characteristics ("common characteristics").


  • All instances are subject to and conform to the same rules and policies ("common behavior").



Since all instances of the class must follow the same rules of behavior, when we abstract a group of like things to produce a class, we also abstract their common behavior pattern into a lifecycle typical of the class. The lifecycle provides a formal description of the behavior pattern shared by each of the objects, called a state machine, as illustrated in Figure 9.12.


Figure 9.12. Correspondence between Abstraction as a Class and as a State Machine



Just as a class has instances, so a state machine also has instances. A state machine instance refers to the execution of a state machine by a particular object. Think of a state machine instance as a private copy of the state machine that is executed by a single object. Each state machine instance is in exactly one state at a time.








    I l@ve RuBoard



    No comments: