Inheritance versus Aggregation

When you derive a new class from an existing base class (that is, when you inherit), you get a copy of the members of the base class. We refer to this as an is-a relationship, as in “A Jeep is a car.”

When a class contains another object, this is referred to as containment or aggregation. However, if you define members in the containing class that are implemented in terms of the contained class, you can make the containing class look a bit like and behave like the contained class. The aggregation relationship is referred to as a has-a relationship.

This promotion of members in a contained object is referred to in .NET vernacular as surfacing constituent object members. Technically, the aggregate can perform some ...

Get Visual Basic® .NET Power Coding now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.