3

Code Smells

The title of this chapter should be self-explanatory or perhaps sounds disgusting, but I think it’s important to explain what is meant by the term code smell. The sensation is similar to when you open the refrigerator and a strange odor hits your nose, something that shouldn’t be there. A bad smell doesn’t necessarily indicate a problem, but it’s worth taking a look, just in case. There might be an issue, or there might not be, but ignoring it is not a good idea.

In our code base, it’s the same. A code smell is a potential problem, a situation in the code that makes us wrinkle our noses. They are very tangible and observable situations, recurring patterns in our projects. They indicate that there is or could be something that needs ...

Get Refactoring in Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.