Home Knowledge Base Divergent Change

Divergent Change is a code smell where a single class is frequently modified for multiple different, unrelated reasons — making it the collision point for changes originating from different concerns, teams, and business domains — violating the Single Responsibility Principle by giving one class multiple distinct axes of change, so that database schema changes, UI requirement changes, business rule changes, and API format changes all require touching the same class independently.

What Is Divergent Change?

A class exhibits Divergent Change when different kinds of changes keep requiring modifications to it:

Why Divergent Change Matters

Divergent Change vs. Shotgun Surgery

SmellSingle ClassMultiple Classes
Divergent ChangeOne class, many change reasons
Shotgun SurgeryMany classes, one change reason

Both indicate SRP violation — Divergent Change is over-concentration, Shotgun Surgery is over-distribution.

Refactoring: Extract Class

The standard fix is Extract Class — decomposing by responsibility:

1. Identify each distinct reason the class changes. 2. For each distinct change axis, create a new focused class containing those responsibilities. 3. Move the relevant methods and fields to each new class. 4. The original class either becomes a thin coordinator referencing the new classes, or is dissolved entirely.

For User: Extract UserProfile (display concerns), UserCredentials (authentication concerns), UserSubscription (billing concerns), UserConsent (GDPR concerns). Each can now change independently without affecting the others.

Tools

Divergent Change is multiple personality disorder in code — a class that has absorbed so many responsibilities from so many different domains that every domain change requires touching it, serializing parallel development, generating constant merge conflicts, and making the entire class increasingly difficult to understand, test, and safely modify as each new responsibility further dilutes its coherence.

divergent changecode ai

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.