Inheritance, Composition, Ruby and You
summary
Argues that Ruby’s method lookup surprises (overriding puts, attr_reader order, Kernel removal) show why inheritance couples classes and complicates unit testing, with concrete ancestor lists and demo outputs. Shows composition via dependency injection via initializer (passing repo and API), small classes, and stubbed tests so behavior isolates and swaps. Recommends inheritance only for API base classes that share headers/error handling, warns Single Table Inheritance inherits the same pitfalls. Examples run and validate the claims.
AI-written summary · about
chapters (8)
- 0:00Introduction to OOP
- 2:30Ruby method lookup
- 9:14Understanding inheritance
- 14:44Understanding composition
- 19:05Inheritance testing issues
- 22:03Composition testing benefits
- 24:20When to use inheritance
- 26:17Summary and Q&A








