Code Smell

Noun · Development · Origin: 1999

Definitions

  1. A surface-level indication in code that usually corresponds to a deeper design problem. Not a bug — the code works — but something about it suggests it could be structured better. Like body odor: not fatal, but a sign something needs attention.

    In plain English: Code that technically works but has signs of being poorly designed — it doesn't crash, but experienced developers can tell something isn't right.

  2. Martin Fowler and Kent Beck cataloged specific smells in 'Refactoring' (1999): Long Method, God Class, Feature Envy, Shotgun Surgery, Primitive Obsession. Each smell has a corresponding refactoring pattern. Recognizing smells is a skill that develops with experience.

    Example: 'This 800-line function with 12 parameters is several code smells at once: Long Method, Long Parameter List, and probably God Class. Time to refactor.'

    Source: catalog / Fowler

Origin Story

Kent Beck's nose for bad code

The term 'code smell' was coined by Kent Beck in the late 1990s during his collaboration with Martin Fowler on *Refactoring*. Beck was looking for a term that conveyed an intuitive sense that something was wrong — not a definitive error, but a warning sign that warranted investigation.

'Smell' was the perfect metaphor: you can't always identify a bad smell precisely, but you know something's off and you should find the source. Fowler cataloged specific smells in his book: Long Method, Feature Envy, Data Clumps, Shotgun Surgery, and dozens more.

The concept gave development teams a non-confrontational vocabulary for code review. Instead of saying 'your code is bad,' a reviewer could say 'I'm getting a Long Method smell here.' The indirection of the metaphor made it easier to discuss code quality without it feeling like a personal attack.

Coined by: Kent Beck

Context: Collaboration with Martin Fowler, late 1990s

Fun fact: Fowler's original book listed 22 code smells. The community has since expanded the catalog to over 100, though some purists argue that dilutes the concept.

Related Terms