Composition over Inheritance

#56 - Refactoring–The Discipline for Writing Good Code - Christian Clausen

Topic 12 of 18

Published Sep 20, 2021 · Clip 30:01–34:15 (4:14)

Christian discusses composition over inheritance, crediting the Gang of Four's Design Patterns book as pioneering design patterns meant to improve architecture at specification time. He argues inheritance creates shared invariants across subclasses you can't view at the same time, coupling them so changing one superclass interface forces changes everywhere — possibly in another team's code. The book's rule 'never use inheritance' is for simplicity; it's 'almost never'. He also reframes object-oriented thinking: objects are like little virtual machines or message-passing people with capabilities (interfaces as certifications), not physical objects, following Dan North's point.