Back to Catalog
Code Smells
Object-Orientation Abusers
Alternative Classes with Different Interfaces
Classes that do the same thing but have different interfaces.
Intent & Description
'
π― Intent
Identify classes that perform similar functions but have different method names or signatures.
π Context
You have multiple classes that essentially do the same thing but use different method names or interfaces, making them inconsistent to use.
π‘ Solution
Unify the interfaces by renaming methods or extracting a common interface.'
Real-world Use Case
Use when similar classes have inconsistent interfaces.
Source
π TL;DR
Similar classes should have consistent interfaces. Unify method names and signatures for better usability.