CouplersLow

Middle Man: What It Costs and How to Fix It

A class that delegates most of its work to another class, adding an unnecessary layer of indirection.

Annual Cost$800 - $6k
Severity
2/5
CategoryCouplers
Detection4 tools

What It Is

A Middle Man is a class whose methods do little more than call methods on another class. It exists as an intermediary that adds no value: it does not transform data, validate inputs, or add behaviour. Middle Men often arise from over-application of the Hide Delegate refactoring (meant to fix Message Chains) or from architectural layers that were added 'for flexibility' but never justified their existence. The result is a class that developers must navigate through to reach the real implementation.

Threshold: When more than half of a class's methods simply delegate to another object with no transformation, the class is a Middle Man. The fix is usually to let callers talk to the delegate directly.

Why It Costs Money

1

Every interaction requires an extra hop. Developers navigating the codebase must open the Middle Man, see that it delegates, and then navigate to the real class. This adds friction to every debugging session and code review.

2

Changes require updating two classes. When the delegate's interface changes, the Middle Man must be updated to match, even though it adds no logic. This doubles the mechanical effort of interface changes.

3

The Middle Man obscures the real architecture. New developers cannot tell from the call site which class actually does the work. They must trace through the Middle Man to find the implementation, adding to onboarding time.

Specific Cost Mechanisms

  • Navigation overhead: extra file to open and understand for every interaction
  • Double maintenance: interface changes require updating both the Middle Man and the delegate
  • Architectural confusion: the real responsibility owner is hidden behind a passthrough layer

Estimated Annual Cost

Cost per instance by team size and codebase size. Based on $120,000 average developer salary. See full methodology.

Team SizeSmall (<50k LOC)Medium (50k-200k)Large (200k+)
3 devs$800$1,800$3,600
5 devs$1,300$3,000$6,000
10 devs$2,000$4,500$6,000
20 devs$2,600$6,000$6,000

How to Detect It

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

SonarQube
squid:S1185

Methods that only call another method with the same parameters

CodeClimate
method-lines

Very short methods that only delegate

PMD
MethodReturnsInternalArray / UseObjectForClearerAPI

Indirect indicators of passthrough methods

Manual
Delegation ratio analysis

If > 50% of methods simply delegate, the class is a Middle Man

Refactoring Patterns

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

Remove Middle Man

The class adds no logic, validation, or transformation

Effort: 1-3 hours
Impact: Eliminates one navigation layer and one file to maintain

Inline Class

The Middle Man and its delegate should be a single class

Effort: 2-4 hours
Impact: Consolidates responsibility in one place

Replace Delegation with Inheritance

The Middle Man genuinely specialises the delegate (rare)

Effort: 2-4 hours
Impact: Converts passthrough into meaningful specialisation

Related Smells