6.8 Accidental DAG Multiple Inheritance via Poor Implementation of Optional Containment

 <  Free Open Study  >  

Poor object-oriented designers who accidentally implement classes with more than one optional component using inheritance will find themselves with a bad case of DAG multiple inheritance. The House class from the previous chapter (Section 5.18) was defined with four optional data members, a heating system, a cooling system, a plumbing system, and an electrical system. If a designer tries to capture these optional data members in an inheritance hierarchy, then he or she will find themselves in trouble (see Figure 6.10).

Figure 6.10. A bad house.

graphics/06fig10.gif

Of course, all of this is unnecessary. The actual solution is to use containment by reference to implement optional data members. (See Chapter 5, Section 5.18, for a description of this solution.)

 <  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