Web apps & software

What is a code smell?

A code smell is a pattern in source code that works today but suggests a design weakness likely to cause bugs or slow changes later. It is a prompt to look closer, not proof that something is broken.

Smells developers often name

  • Long function: one routine handling validation, pricing, saving and emailing.
  • Duplicated logic: the same tax calculation pasted into four screens, so a rate change misses one.
  • Large class: an "Order" object that also knows about shipping labels and refunds.
  • Magic numbers: a bare 86400 in the middle of a calculation instead of a named constant.
  • Shotgun surgery: one small business change forces edits in a dozen files.

What to do about them

Smells are fixed by refactoring in small, tested steps. Not every smell deserves attention: a rarely touched script can stay ugly. Prioritize the areas the team changes every week, because that is where the smell costs real time.

For non-technical owners

A reviewer who reports smells is describing future cost. Ask which ones sit in the parts of the product you plan to extend, and fix those first.

Questions, answered

Not always, but they make mistakes more likely because the code is harder to read and change safely.

Linters and static analysis tools catch many of them, but design smells still need a human reviewer.

By the Stegnor team · Updated