Code Smells

Code Smells / Change Preventers / Shotgun Surgery

Shotgun Surgery code smell icon

Shotgun Surgery

Shotgun Surgery smells occur when a single change requires edits in many classes.

The consequence of this is that you can easily cause errors whenever a change is made that outside classes do not expect, limiting how quickly you can make changes to the code.

The aim should be that code changes and classes have a one-to-one relationship (each change affects only one class). Shotgun Surgery smells are one-to-many (one change affects many classes).

Shotgun Surgery is the opposite of Divergent Change.

Left chevron Right chevron

Books about code smells

Learn to write better smelling code.

Refactoring: Improving the Design of Existing Code book cover

Refactoring: Improving the Design of Existing Code

Code smells: A Predictor of Remarkable Quality Improvement book cover

Code smells: A Predictor of Remarkable Quality Improvement

Clean Code: A Handbook of Agile Software Craftsmanship book cover

Clean Code: A Handbook of Agile Software Craftsmanship

I receive a commission on sales made from the above affiliate links.