Subclassing vs Composition: A Survey of Trade-offs in Python
summary
Examines trade-offs between subclassing and composition in Python, naming different forms of subclassing and patterns used in the language. Uses Python examples to show when subclasses make code more Pythonic versus when composition improves clarity, aiming to give practical guidance rather than dogma.
AI-written summary · about
chapters (10)
- 0:00Introduction to class design
- 1:34Subclassing vs composition
- 5:11Complexity of hierarchies
- 8:46Template subclassing issues
- 12:54Implementing clean interfaces
- 18:32Architecture and testability
- 22:19Namespaces and encapsulation
- 25:28Trade-offs in design
- 31:37When to use subclassing
- 39:00Conclusion and takeaways








