The same switch (or if/else chain) over a type code appears in multiple places — adding a new case means hunting them all down.
The agent finds the same switch (or if/else chain) over a type code in multiple files; adding a new case requires the agent to grep for every site and update each consistently.
Each case is a class implementing a shared interface; dispatch happens once via a virtual call.
Each case is a class implementing a shared interface; the agent adds a new case by adding one class, and the type checker tells it what's still missing.
Smellier version
switch (event.kind) {case 'click': return onClick(event);case 'key': return onKey(event);case 'drag': return onDrag(event);}
Fresher version
event.handle(); // ClickEvent, KeyEvent, DragEvent each implement handle()
Dispatch logic is duplicated across the codebase; new cases are easy to miss; the type-code couple amplifies.
Dispatch logic duplicates across files; new cases are easy to miss; chained edits across all switch sites compound the agent's review burden per change.
Replacing the switch with polymorphism scatters dispatch across classes; adding a new case is one new file, but understanding the full dispatch surface now requires reading several.
Polymorphic dispatch is implicit at call sites — the agent can no longer see the full set of branches in one place and must enumerate subclasses across files to reason about behavior.
Adding a new case is one new class; the compiler and tests surface what's missing.
Adding a new variant is mechanical and the type checker enforces completeness; the agent's plan-and-execute loop for new cases is bounded.
Polymorphism worship — a switch with two stable cases becomes a class hierarchy of two trivial subclasses, paying class-hierarchy overhead with no flexibility return.
Replacing every switch with polymorphism, even ones with two stable cases, creates a class hierarchy the agent must navigate without buying any extension flexibility.