Chapter 11. Inheritance
The relationship between a class and its subclass often starts being simple but gets more complicated over time. A subclass often depends on its parent more intimately than does a separate class, but it can go too far.
A key challenge is deciding what a class is (behaves like) versus what a class has or knows. A class structure often starts with inheritance and moves to a more compositional style over time.
In this chapter we’ll cover the following smells:
• Implementation Inheritance, in which subclassing is used purely to reuse code
• Refused Bequest, in which a subclass isn’t substitutable for its superclass
• Inappropriate Intimacy (Subclass Form), in which a subclass is tangled up in its superclass’s implementation ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access