As your codebase grows, you will have instances where you have code that needs to be reused. Then you think, I can do this with subclassing! Now you have a diamond-tree of problems.
Here, we’ll talk about a better way of code reuse and introducing alternate behaviour into existing classes — composition. It’ll improve how you test your code — making your test runs faster, making it easier to test exceptional cases, and making everything easier to understand.
Amber, better known as HawkOwl, is a core developer and release manager of the Twisted project. In her spare time she writes web applications, works on Twisted, and organizes events such as GovHack and Django Girls. Loves bright colours, Earl Grey tea, and nail polish.