Composition over Inheritance
Updated 2026-07-31
Summary
When building systems, prioritize implementing functionality by assembling simple components (composition) rather than establishing deep hierarchical relationships (inheritance).
Definition
When building systems, prioritize implementing functionality by assembling simple components (composition) rather than establishing deep hierarchical relationships (inheritance). Scaffold use: Lego-like flexibility. Don't try to design a universal 'parent class' for everyone to inherit (inheritance leads to rigidity and fragility). Make small, beautiful building blocks that can be plugged in wherever needed. In organizational design, forming flexible project teams (composition) is superior to rigid bureaucracy (inheritance).
Introduction
How to use
Lego-like flexibility. Don't try to design a universal 'parent class' for everyone to inherit (inheritance leads to rigidity and fragility). Make small, beautiful building blocks that can be plugged in wherever needed. In organizational design, forming flexible project teams (composition) is superior to rigid bureaucracy (inheritance).
Mechanism
Prioritize assembling simple components (composition) to implement functionality, rather than building deep hierarchical inheritance. Inheritance easily leads to rigidity and fragility (changes in the parent class affect subclasses), while composition is more flexible, replaceable, and reduces coupling.
Practice
In progress 0/4Practice this model in one real situation:
Cases
- Using plugin composition rather than large parent class inheritance makes the system easier to evolve.
Common pitfalls
- Forcing deep inheritance for reuse; over-composition leading to fragmentation; neglecting necessary inheritance.
Sources
Source support: Explicit
References currently contain only Wikipedia links; primary sources still need review.
- en.wikipedia.orghttps://en.wikipedia.org/wiki/Composition_over_inheritanceverified
account_treeGenealogyexpand_more
PRIVATE NOTES · Only visible to you
SAVED Q&A
ENTRY Q&A · Private saving available
Ask with a clear boundary
thinkingmodels answers from published entry context only.
Your question is sent to thinkingmodels. The answer uses public entry context only.
RELATED MODELS