Object-Orientation AbusersMedium

Alternative Classes with Different Interfaces: What It Costs and How to Fix It

Two or more classes that perform similar functions but have incompatible method names and signatures.

Model cost, team of 8$4K-$12K/yr
Severity
3/5
CategoryObject-Orientation Abusers
Detection4 tools

What It Is

This smell occurs when two or more classes do essentially the same thing but expose different interfaces. For example, one notification class uses send(message, recipient) while another uses dispatch(payload, target). Callers cannot use them interchangeably, so switching between implementations requires rewriting all call sites. The classes should implement a common interface, but because they were written independently (often by different developers or at different times), they diverged in naming and structure.

Threshold: When two classes have 3+ methods that do the same thing with different names, extract a shared interface. When you find yourself writing adapters between similar classes, the smell is confirmed.

Why It Costs Money

1

Switching implementations requires rewriting call sites. When you decide to replace one email sender with another, every caller must change because the method names and parameter structures differ.

2

Code that should be generic must be duplicated. You cannot write a single function that works with both classes, so you write adapter code or duplicate logic.

3

Testing doubles are inconsistent. Mocks for one implementation do not work for the other, doubling test maintenance.

Specific Cost Mechanisms

  • ●Implementation switching: rewriting call sites on every switch, where a shared interface would make it near-free
  • ●Adapter proliferation: wrapper classes that translate between interfaces add complexity and maintenance cost
  • ●Duplicate test infrastructure: separate mocks and test setups for functionally identical classes

Estimated Annual Cost

Cost of one instance a year by team size, from our model at $180K fully-loaded cost per engineer. Low and high use the bottom and top of the Medium inputs; mid is halfway. See full methodology.

Team SizeLowMidHigh
3 devs$2K$4K$5K
5 devs$3K$5K$8K
8 devs$4K$8K$12K
10 devs$5K$10K$15K
20 devs$9K$19K$28K

These are model outputs, not measurements. Every input is on the cost model page, and the same model produces the figures on the 22 smells page. Put in your own team and cost in the smell profile calculator.

How to Detect It

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

SonarQube
squid:S1214

Interface segregation violations (indirect)

CodeClimate
similar-code

Detects structurally similar classes with different names

PMD
LooseCoupling

Flags concrete type references that should use interfaces

IntelliJ IDEA
Extract interface suggestion

Suggests shared interfaces when similar classes are detected

Refactoring Patterns

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

Extract Superclass/Interface

Two classes have overlapping behaviour that should be unified

Effort (our estimate): 2-4 hours
Impact: Enables polymorphic usage and eliminates adapter code

Rename Method

Classes do the same thing but use different names

Effort (our estimate): 30-60 minutes per method
Impact: Aligns interfaces for future extraction

Move Method

Behaviour in one class belongs in the other

Effort (our estimate): 1-3 hours
Impact: Consolidates duplicated behaviour

Related Smells

Updated November 2026