Composition vs Inheritance
Building behavior by combining smaller objects (composition) vs extending a base class (inheritance) — composition is generally favored for flexibility.
Why we need this / what value this brings
Deep inheritance hierarchies get brittle fast — a change to a base class can break every subclass in ways that are hard to trace; composition avoids that by building behavior from small, independent pieces.
When to use this
Default to composition; reach for inheritance only for a genuine 'is-a' relationship with shared, stable behavior.
How to use or implement this
Ask 'does B need to BE an A, or does B just need to USE some of A's behavior' — the second case should be composition (B holds a reference to an A), not inheritance.
Research questions
- Where in the codebase would a deep inheritance hierarchy be better replaced by composing smaller, focused objects?
Empty folder — drop notes, links, and findings here as you research.