DEV Community

Discussion on: Code Smell 125 - 'IS-A' Relationship

Collapse
 
codenameone profile image
Shai Almog

Inheritance reduces duplication in code. In fact the original "wrong" approach can be written with less code and allows for polymorphism which is a core tenant of OOP. E.g. in Java Shape is a base interface for many shape objects.

The problem with IS A relates to overuse and detachment from semantics. Using it instead of composition etc. But having a common based class or hierarchy, that's good.

Collapse
 
mcsee profile image
Maxi Contieri

Yes!

That is exactly why this is just a "smell" and not a directive.
I agree with you overuse and detachment from semantics are the symptoms