6.5 Frameworks That Incorporate Multiple Inheritance

 <  Free Open Study  >  

Consider a modification to our notion of WoodenDoor , where we take into consideration the fact that doors have a body of some material (e.g., wood, steel, plastic), hinges of some material (e.g., brass, steel, gold), an optional window of some material (glass, plastic, Plexiglass), and a door knob of some material (e.g., steel , brass, wood). This implies that there is only one door class, but it is implemented as a framework (see Figure 6.6). The multiple inheritance is simply pushed down into the framework of the door.

Figure 6.6. A framework for doors.

graphics/06fig06.gif

Like all frameworks, this framework captures information relevant to the design of doors as well as the code that implements doors. By adding a new derived class to one of the contained base classes, we create the possibility for a number of different object constructions. For example, by adding a steel hinge to our domain, we create the possibility of having wooden doors with steel hinges, steel doors with steel hinges, etc.

 <  Free Open Study  >  


Object-Oriented Design Heuristics
Object-Oriented Design Heuristics (paperback)
ISBN: 0321774965
EAN: 2147483647
Year: 1996
Pages: 180

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