Methods should be interchangeable if they do the same.
Problems
Missed Polymorphism
Coupling
IFs / Type check Polluting
Names coupled to types.
Solutions
Rename methods after what they do.
Favor polymorphism.
Sample Code
Wrong
Right
Detection
This is a semantic mistake. We could add a warning for similar method names on Polymorphic classes.
Tags
- Polymorphic
Conclusion
Naming is very important. We need to name after concepts and not after accidental types,
Relations
![mcsee](https://res.cloudinary.com/practicaldev/image/fetch/s--by_E26Wt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://res.cloudinary.com/practicaldev/image/fetch/s--XvnZDWAZ--/c_fill%2Cf_auto%2Cfl_progressive%2Ch_150%2Cq_auto%2Cw_150/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/366059/69feb7c3-ab01-4bcd-a6f5-ec38e9300da3.jpeg)
Code Smell 36 - Switch/case/elseif/else/if statements
Maxi Contieri ・ Nov 28 '20
More info
If you have three pet dogs, give them names. If you have 10,000 head of cattle, don't bother. Nowadays, the idea of giving a name to every file on your computer is ridiculous.
David Gelernter
Top comments (0)