composition-over-inheritance

Installation
SKILL.md

Composition Over Inheritance

"Favor object composition over class inheritance" is the second principle of object-oriented design in the GoF's Design Patterns (1994). Their reasoning was not stylistic: inheritance is white-box reuse — the parent's internals are visible to and depended on by the child, so "inheritance breaks encapsulation." Composition is black-box reuse through well-defined interfaces, and it can be reconfigured at runtime, while an extends clause is fixed at compile time. The default that survives change is has-a plus interfaces; inheritance is the deliberate exception.

The fragile base class, in one paragraph

Installs
1
GitHub Stars
1
First Seen
Sep 18, 2026