39.7 The Mixin Pattern: Composable Class Extensions
Right, so you want to build a class that does one thing well, but you also want it to be able to do a dozen other, often unrelated, things. You could write a monolithic GodClass that does everything from sorting arrays to brewing coffee, but then you’d be stuck maintaining that monstrosity forever. Or, you could engage in the deeply tedious ritual of classical inheritance, chaining together extends statements until your class declaration looks like a family tree drawn by a bored medieval scribe.