Chapter 6. Acquiring Behavior Through Inheritance
Well-designed applications are constructed of reusable code. Small, trustworthy self-contained objects with minimal context, clear interfaces, and injected dependencies are inherently reusable. This book has, up to now, concentrated on creating objects with exactly these qualities.
Most object-oriented languages, however, have another code sharing technique, one built into the very syntax of the language: inheritance. This chapter offers a detailed example of how to write code that properly uses inheritance. Its goal is to teach you to build a technically sound inheritance hierarchy; its purpose is to prepare you to decide if you should.
Once you understand how to use classical inheritance, the ...
Get Practical Object-Oriented Design in Ruby: An Agile Primer now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.