Skip to content

code smell

A code smell is a surface indication in source code that usually corresponds to a deeper problem in the system’s design, even though the code still runs correctly. The term names a hint worth investigating rather than a defect to fix on sight.

Kent Beck coined the phrase while helping Martin Fowler write his book Refactoring, where it grew into a vocabulary for naming recurring structural weaknesses. A smell is meant to be quick to spot and quick to name.

A method that runs to hundreds of lines, a class that hoards unrelated responsibilities, or the same logic copied across several files each carry a recognizable scent. None is a bug on its own, so a smell raises a question rather than answering it.

Catalogs of smells sort the common ones into broad families:

Code smell branches into five families, Bloaters, OO abusers, Change preventers, Dispensables, and Couplers.
The Five Families a Smell Falls Into
  • Bloaters: Methods, classes, or parameter lists that have grown unwieldy.
  • Object-orientation abusers: Incomplete use of object-oriented features, such as a switch that a polymorphic call would replace.
  • Change preventers: Structures where one edit forces matching edits in many scattered places.
  • Dispensables: Code that adds nothing, such as dead code or redundant comments.
  • Couplers: Classes bound too tightly, such as feature envy or a long chain of calls.

A smell is normally resolved through refactoring, reshaping the code without changing its behavior. Left unaddressed, accumulated smells are a common source of technical debt. A linter can flag mechanical smells, but judging whether one marks a real problem still calls for human review.

Python Code Quality Illustration

Tutorial

Python Code Quality: Best Practices and Tools

In this tutorial, you'll learn about code quality and the key factors that make Python code high-quality. You'll explore effective strategies, powerful tools, and best practices to elevate your code to the next level.

intermediate best-practices python tools

For additional information on related topics, take a look at the following resources:


By Martin Breuss • Updated July 21, 2026