QamoosTech
Programming FundamentalsCode qualityIntermediate

Code Smell

Pronunciationkohd smel

Definition

A sign in the code that something may be wrong with its design, such as a very long function or the same logic copied in many places. It is not a bug, but it makes change harder.

Where you hear it

In code reviews, when a reviewer says "this smells", and in refactoring discussions.

Examples

  • This function has 200 lines, which is a code smell.
  • The same validation appears in five places, a clear code smell.
  • The long function is a code smell, so we split it before adding the new discount logic.

Common mistake

Treating every code smell as a bug to fix right away. A smell is a hint to look closer, not an order to rewrite.

Don't confuse with

A code smell is a hint that the design may be weak. A bug is behaviour that is wrong today.