Tool Abusers

These are misused smells in object-oriented programming.

Tool Abusers, also known as "object-oriented abusers", are a type of code smell that only occurs in object-oriented programming (OOP) languages. This code smell refers to incorrect or incomplete implementation of Object-Oriented concepts or principles.

If the only tool you have is a hammer, you tend to see every problem as a nail. β€” Abraham Maslow

This is a famous quote commonly known as the "law of the instrument" or Maslow's Hammer. We sometimes over-rely on a familiar or favorite tool in the wrong way. "The code we write is a tool for producing future software," said Roman Kofman at RubyConf 2019. OOP may be the most powerful concept in the programming world. Billions of developers work with OOP every day, but not every line of code follows OOP principles properly.

As you may know, some developers have been criticizing OOP for decades, blaming it for various development challenges and inefficiencies. While it is true that certain pitfalls can arise in OOP, some of the criticism might just be pointing to code smells. It's important to recognize that these criticisms often arise from misuses and code smell issues rather than inherent flaws in the paradigm itself.

In my point of view, OOP, when applied correctly with adherence to best practices, can lead to highly maintainable, scalable, and modular codebases. These are ideas that are available in object-oriented programming that you may misuse.

Repeated Conditional Complexity

When you encounter complex "switch" statements or sequences of "if" statements in your code, it's a sign of this code smell.

Refused Bequest

When a class unnecessarily inherits code from its parents.

Alternative Classes with Different Interfaces

It appears that two different classes are performing similar responsibilities, but have different interfaces (method names, signatures, etc.).

Temporary Field

Fields in the Class that are used only by one Method or only under certain circumstances.

Reference

https://bytelanguage.com/2018/02/25/code-smells-object-oriented-abusers/

https://refactoring.guru/refactoring/smells/oo-abusers

Last updated