DEV Community

Discussion on: Explain "Code Smells" like I'm five

Collapse
 
nbilyk profile image
Nicholas Bilyk

Code is said to "smell" when it doesn't follow best practices, isn't idiomatic (not standard), or is likely to be error prone.
To me, it's a lazy (and often condescending) way to describe issues in a code. "That has a bad smell." Well, why? Elaborate.

Sometimes it means an intuition that something can be improved, but the reviewer lacks the vocabulary to say why or how.

For example if you have code that is supposed to determine the state of a button based on user interaction, and it's 500 lines of code, something is definitely wrong there, that code is going to "smell". An experienced engineer might recommend better design patterns, give ideas how to reduce the complexity, illuminate a path towards something more elegant, maintainable, and most importantly, stable.