Slow Down, Compose Yourself
summary
Argues for composition instead of deep inheritance and shows concrete wins: build an in-memory storage for a blog API and swap implementations via clearly defined interfaces, replace heavyweight DB tests to cut runs from minutes to seconds, and use a reactor that runs in memory for Twisted so the full test suite of 3,000 tests in a minute is possible. Demonstrates composition with Django-style views, Twisted backends and cryptography backends, and proves improved testability, faster CI, and simpler fault injection.
AI-written summary · about
chapters (19)
- 0:00Intro
- 1:40No software is unchanging
- 1:51Extend, improve, replace
- 2:47You write mixins to alter behavour of subclasses, and reduce duplication
- 4:13Why you should slow down
- 4:48Modularity and testability are two very desirable traits
- 5:07Modularity helps testability
- 5:17Tests are the only way to validate something works and keeps working
- 5:52When designing a system, you might want to aim for these traits
- 6:13Composition is when logic is made up of smaller blocks of logic
- 7:35Replacing the real components with fake ones reduces the surface area to test
- 12:22Write an example of your code being used
- 13:01Design the API "experience"
- 18:24Testing with Composition
- 19:00Test the components in isolation
- 19:17Test with the parts integrated
- 19:31Correctness at every level
- 19:43Object Composition & Function Composition
- 22:40Twisted (the newer parts)
related talks
29mBest Practices for Compose-managed Python Apps
28m"WHAT IS THIS MESS?" - Writing tests for pre-existing code bases
46mCompositional Testing in Python
53mDjango productivity tips and tricks
56mLightning Talks
44mTDD (Pythonowych) Mikroserwisów
31mTechnical Lessons Learned from Pythonic Refactoring
30mAn Admin's Cornucopia - Python Is More Than Just A Better Bash
