You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactoring: Improving the Design of Existing Code
book
isbn_13
isbn_10
978-0201485677
0201485672
Shotgun Surgery
Similar to Divergent Change, but with a broader spectrum, the smell symptom of the Shotgun Surgery code is detected by the unnecessary requirement of changing multiple different classes to introduce a single modification. Things like that can happen with the failure to use the correct design pattern for the given system. This expansion of functionality can lead to an easy miss (and thus introduce a bug) if these small changes are all over the place and they are hard to find. Most likely, too many classes solve a simple problem.
Joshua Kerievsky noted this smell as Solution Sprawl [1]. Monteiro stated that the tiny difference between these two comes from how they are sensed. In the Shotgun Surgery, one becomes aware of the smell while making the changes, and in the Solution Sprawl, one is aware by observing the issue. [2]
Causation
Wake says it could have happened due to an "overzealous attempt to eliminate Divergent Change" [3]. A missing class could understand the entire responsibility and handle the existing cluster of changes by itself. That scenario could also happen with cascading relationships of classes [4].
Problems
Single Responsibility Principle Violation
The codebase is non-cohesive.
Duplicated Code
The increased learning curve for new developers to effectively implement a change.