Composition Quote by Joshua Bloch
“Favor composition over inheritance,”
About This Quote
Source Book: Effective Java, 2nd Edition, 2008
Prioritize designing code by composing smaller, reusable components rather than relying on inheritance hierarchies.
In simple terms: Prefer composition over inheritance in code design.
Use composition for flexible, maintainable software.
Themes
Mood
Type
When to use this quote
- API design
- refactoring
- team collaboration
- system architecture
Key Concepts
Questions to Reflect On
- When might inheritance be justified?
- How does composition improve testability?
Inheritance can create rigid, fragile structures.