Inheritance vs Composition

This lesson discusses the reasons why composition may be a better choice than inheritance.

We'll cover the following...

Notes on Inheritance vs Composition

  1. Class (not interface) inheritance may be inappropriate across package boundaries since the subclass will need to evolve alongside the superclass and is prone to breaking if the superclass undergoes changes. The resulting software is fragile and less maintainable.

  2. Composition is an alternative to inheritance. Composition works by ...