Remove Middle Man

Removes smells
Compare
Symptom
Human

A class whose methods are nearly all delegations to one collaborator object — no decisions, no transformations, just passthrough.

Agent

A class whose methods all delegate straight through to another object; the agent traces every call to the real implementation through the passthrough hop.

Goal
Human

Callers talk directly to the real object; trivial passthroughs are deleted.

Agent

Callers talk to the real object directly; the agent's call traces are shorter and the implementation's location is obvious.

Before the refactoring

class Manager {
reports() { return this.team.members(); }
}

After the refactoring

// Expose team directly when the wrapper adds nothing.
manager.team.members();
Example source: Illustrative example written for this site, not a quotation from any source.
Pressure
Human

Every consumer pays a hop to reach the real implementation; the middle man adds file count and indirection with no value; future maintenance must update both classes for any change to the delegated API.

Agent

The agent navigates the indirection on every reasoning step; refactoring the delegate's API requires the agent to update both classes in sync.

Tradeoff
Human

Direct access to the delegate exposes its surface to every consumer — only remove the middle man when most of its methods are passthroughs.

Agent

Direct access exposes the real object's full surface to every consumer; the agent loses any encapsulation the middle man was providing (even if mostly cosmetic).

Relief
Human

Fewer files, shorter call stacks, the implementation's location is obvious.

Agent

Fewer files; shorter call stacks; the agent's plan-and-execute loop touches the real implementation directly.

Trap
Human

Deleting a middle man that's actually doing real work — authorization, validation, auditing — that the trivial-looking delegations were quietly enforcing.

Agent

Deleting a passthrough that was doing real work — authorization, validation, auditing — removes a load-bearing layer the agent didn't recognize because the trivial-looking delegation masked it.