Code Safari

Chapter 97·Beginner

Composition Over Inheritance: The Advice You'll Hear Most

01 / 04

The core idea

Prefer 'has-a' to 'is-a'.

Build bigger objects by combining smaller ones (composition) rather than climbing a class tree (inheritance). The most repeated piece of OOP design advice.

Composition Over Inheritance: The Advice You'll Hear Most | Code Safari