Inheritance and Composition                 
                                              
Many developers make the mistake of overusing inheritance. To avoid this mistake, keep the following in mind:
      •        Inheritance causes a tight coupling between classes.
      •        Derived classes can become overly dependent on base class implementation details. If those details     
               change, the derived classes can be broken.
      •        Only use inheritance if you can logically state, "Class A is a type of Class B."

Composition establishes a "has-a" relationship. In other words, Object A has an Object B. In VB  this
relationship is realized as a field in Class A that is typed as Class B. For example, let’s say that an employee
object maintains another object that represents the employee's benefit selections:


Public Class Employee
   Private mBenefits As BenefitPackage
 
   Public Sub New()
      mBenefits = New BenefitPackage("Standard")
   End Sub
End Class
Copyright (c) 2008.  Intertech, Inc. All Rights Reserved.  This information is to be used exclusively as an
online learning aid.  Any attempts to copy, reproduce, or use for training is strictly prohibited.
Composition
Table of Contents
Courseware
Training Resources
Tutorials
Services