In the previous articles in this series we’ve seen:
- How to identify a God Class
- How to identify Feature Envy
- How to identify a Data Class
- How to identify a Brain Method
- How to identify Intensive Coupling and Dispersed Coupling
In this article we’ll see how to identify an afferent (incoming) coupling code smell: Shotgun Surgery.
Shotgun Surgery Detection Strategy
A method suffers from Shotgun Surgery if it is called many times from many other classes. Object-Oriented Metrics in Practice, by Michele Lanza and Radu Marinescu, proposes the following detection strategy for Shotgun Surgery:
(CM > Short Memory Cap) AND (CC > Many)