0Pricing
Dart Academy · Lesson

Composition Over Inheritance

Prefer has-a designs where they fit.

Two Ways to Reuse

You can reuse behavior by inheriting it or by holding another object. The second approach is called composition.

is-a vs has-a

Inheritance models is-a: a Circle is a Shape. Composition models has-a: a Car has an Engine.

All lessons in this course

  1. Abstract Classes and Abstract Methods
  2. Implicit Interfaces and implements
  3. Polymorphism Through Shared Types
  4. Composition Over Inheritance
← Back to Dart Academy