One change, many files
Shotgun surgery signals that the same business concern is spread too widely.
Shotgun surgery and divergent change are two closely related failure patterns. Shotgun surgery means one conceptual change requires edits in many places. Divergent change means one module keeps changing for many unrelated reasons. Together, they reveal a design where coupling is high and cohesion is weak.
If a new payment rule forces changes in controllers, services, repositories, DTO mappers, and notification code, the design is not merely inconvenient. It is structurally amplifying change. That is one of the clearest signs that responsibility and dependency direction need work.
These patterns make change expensive in opposite but related ways. Shotgun surgery spreads one concept across too many modules. Divergent change concentrates too many concepts inside one module. Both indicate poor responsibility shaping.
In Java teams, these failures often appear when features grew incrementally without revisiting the model. New code was added where it fit tactically, not where it belonged structurally. Over time, the result is a codebase where change scope is hard to predict.
Refactoring here often involves re-centralizing one business concern into a better boundary while splitting overgrown classes or packages into narrower responsibilities.
Shotgun surgery signals that the same business concern is spread too widely.
Divergent change signals that a class or package has become too broad in responsibility.
These anti-patterns are among the clearest indicators that refactoring has real business value.
package org.javaomnibus.ecommerce.antipatterns;
public final class OrderController {
public void applyDiscount(CheckoutRequest request) {
// validates discount input
}
}
public final class PricingService {
public Money totalFor(Order order) {
// applies discount policy
return Money.zero("USD");
}
}
public final class NotificationTemplateBuilder {
public String discountMessage(Order order) {
// builds text for discount-related emails
return "discount applied";
}
}
Sometimes a concern legitimately touches several areas, so not every multi-file change is pathological. The anti-pattern appears when the spread feels accidental and repeatedly unpredictable.