August 2003
Intermediate to advanced
224 pages
3h 30m
English
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.
Refused Bequest
Inappropriate Intimacy (Subclass Form)
Lazy Class
See also these other smells related to inheritance:
Simulated Inheritance (Switch Statement), Chapter 7
Parallel Inheritance Hierarchies, Chapter 11
Combinatorial Explosion, Chapter 11
A class inherits from a parent, but throws an exception instead ...
Read now
Unlock full access