Change PreventersHigh

Shotgun Surgery: What It Costs and How to Fix It

A single logical change requires small edits scattered across many different classes or files.

Model cost, team of 8$6K-$24K/yr
Severity
4/5
CategoryChange Preventers
Detection4 tools

What It Is

Shotgun Surgery is the inverse of Divergent Change. Where Divergent Change means one class changes for many reasons, Shotgun Surgery means one reason causes changes in many classes. For example, adding a new user field requires editing the User model, the database migration, the API controller, the serialiser, the form component, the validation logic, and the test fixtures. Each edit is small, but missing any one creates an inconsistency. The scattered nature of the change makes it easy to forget a location and hard to verify completeness.

Threshold: If a single conceptual change (add a field, change a business rule) requires editing 4+ files, you have Shotgun Surgery. Git commit history showing files that always change together is the most reliable detection method.

Why It Costs Money

1

Incomplete changes are the primary cost. When a change requires touching 8 files and a developer updates 7, the missed file creates a bug that may not surface until production. These partial-change bugs are expensive because they pass all automated tests for the files that were updated.

2

Change effort is multiplied. A conceptually simple change (add a field, rename a status) requires opening, understanding, modifying, and testing many files. Developer time scales linearly with the number of scattered edit sites.

3

Knowledge requirements are unreasonable. The developer making the change must know all the places that need updating. This knowledge is rarely documented and lives in the heads of senior team members, creating a bus factor risk.

Specific Cost Mechanisms

  • ●Partial-change bugs: each missed edit site has to be diagnosed and fixed after it reaches production
  • ●Multiplied effort: each scattered change has to be found, made and tested in every class it touches
  • ●Knowledge dependency: only senior developers who know all the edit sites can safely make changes

Estimated Annual Cost

Cost of one instance a year by team size, from our model at $180K fully-loaded cost per engineer. Low and high use the bottom and top of the High inputs; mid is halfway. See full methodology.

Team SizeLowMidHigh
3 devs$3K$7K$11K
5 devs$4K$10K$16K
8 devs$6K$15K$24K
10 devs$7K$19K$30K
20 devs$14K$35K$57K

These are model outputs, not measurements. Every input is on the cost model page, and the same model produces the figures on the 22 smells page. Put in your own team and cost in the smell profile calculator.

How to Detect It

Specific rules and thresholds for automated detection. See full tool comparison.

SonarQube
squid:S1200

High coupling between classes indicates scattered responsibilities

CodeClimate
similar-code

Repeated patterns across files suggest shotgun surgery

Git analysis
Co-changed file analysis

Files that always change together in commits indicate shotgun surgery

CodeScene
Change coupling analysis

Identifies files with high co-change frequency

Refactoring Patterns

Proven techniques to eliminate this smell. See all refactoring patterns.

Move Method/Field

Behaviour scattered across classes belongs in a single class

Effort (our estimate): 2-6 hours
Impact: Localises change to one file instead of many

Inline Class

A class exists only to hold one piece of a scattered concern

Effort (our estimate): 2-4 hours
Impact: Reduces the number of files that change for a single reason

Extract Class (centralise)

The scattered edits all serve a concept that deserves its own class

Effort (our estimate): 4-12 hours
Impact: Creates a single point of change for the concept

Related Smells

Updated November 2026