Shotgun Surgery
ELI5 — The Vibe Check
Shotgun surgery is when one small change requires you to modify dozens of files across the codebase — like firing a shotgun and hitting everything. Want to rename a field? Good luck, it's referenced in 43 files, 12 services, and 3 databases. It's a sign your code is too tightly coupled and one of the most dreaded code smells.
Real Talk
Shotgun surgery is a code smell identified by Martin Fowler where a single logical change requires many small edits across multiple classes or modules. It indicates poor encapsulation and excessive coupling. The remedy typically involves consolidating related behavior using the Move Method or Move Field refactoring patterns.
When You'll Hear This
"Adding a new user field requires shotgun surgery — it touches every layer." / "If a change needs more than 5 files, you've got shotgun surgery."
Related Terms
Code Smell
Code Smell is when code isn't technically broken but something feels off — like a 500-line function, a class named 'Manager' that does everything, or a com...
Coupling
Coupling is how much two pieces of code depend on each other. Tight coupling means changing one breaks the other — like Siamese twins.
DRY (Don't Repeat Yourself)
If you find yourself copy-pasting the same code in multiple places, STOP. Make it a reusable function instead.
Feature Envy
Feature envy is when a function spends more time poking around in another class's data than its own.
Refactor
Refactoring is cleaning and reorganizing your code without changing what it does — like tidying your room without throwing anything away.