You are previewing Practical Object-Oriented Design in Ruby: An Agile Primer.

Practical Object-Oriented Design in Ruby: An Agile Primer

Cover of Practical Object-Oriented Design in Ruby: An Agile Primer by Sandi Metz Published by Addison-Wesley Professional
O'Reilly logo

Chapter 7. Sharing Role Behavior with Modules

The previous chapter ended on a high note, with code that looked so promising you may be wondering where it’s been all your life. However, before you decide to use classical inheritance to solve every imaginable design problem, consider this: What will happen when FastFeet develops a need for recumbent mountain bikes?

If the solution to this new design problem feels elusive, that’s perfectly understandable. Creation of a recumbent mountain bike subclass requires combining the qualities of two existing subclasses, something that inheritance cannot readily accommodate. Even more distressing is the fact that this failure illustrates just one of several ways in which inheritance can go wrong.

To reap ...

The best content for your career. Discover unlimited learning on demand for around $1/day.