O'Reilly logo

Refactoring Workbook by William C. Wake

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9. Inheritance

The relationship between a class and its subclass often starts being simple but gets more complicated over time. A subclass will often depend on its parent more intimately than will a separate class, but it can go too far.

A key challenge is deciding what a class is versus what a class has. A class structure often starts with inheritance and moves to a more compositional style over time.

Smells Covered

  • Refused Bequest

  • Inappropriate Intimacy (Subclass Form)

  • Lazy Class

See also these other smells related to inheritance:

Refused Bequest

Symptoms

  • A class inherits from a parent, but throws an exception instead ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required