Code Smell 11 — Subclassification for Code Reuse
Code reuse is good. But subclassing generates a static coupling.
Code reuse is good. But subclassing generates a static coupling.

Problems
Coupling
Maintainability
Solutions
Favor composition.
Exceptions
If hierarchy follows the principle behaves like then it is safe.
Sample Code
Wrong
Right
Detection
Overriding can issue warnings when subclassing concrete methods.
Deep Hierarchies (more than 3 levels) are also a clue of bad subclassing.
Tags
Composition
Conclusion
In legacy systems is very common to have Deep Hierarchies and method overriding, we need to refactor them and subclass by essential reasons and not implementative ones.
More info
This article is part of the CodeSmell Series.
How to Find the Stinky parts of your Code
The code smells bad. Let’s see how to change the aromas.medium.com