A *code smell* is a surface indication in source code that usually signals a deeper problem in the system’s design. It is not a bug—code with smells often works correctly—but it suggests weaknesses that may hinder future development, readability, or maintainability.
The term was first popularized by Kent Beck while he was working with Martin Fowler on the book *Refactoring: Improving the Design of Existing Code* (1999). Beck coined the phrase "code smell" to describe these warning signs in code, and Fowler expanded on the idea by cataloguing common examples and linking them to specific refactoring techniques.
Examples of code smells include duplicated logic, long methods, large classes, feature envy, and inappropriate intimacy between modules. Addressing these often involves restructuring code without changing its external behavior, improving overall clarity and flexibility.
# Classic Code Smells - Duplicated Code - Long Method - Large Class - Long Parameter List - Divergent Change - Shotgun Surgery - Feature Envy - Data Clumps - Primitive Obsession - Switch Statements - Parallel Inheritance Hierarchies - Lazy Class - Speculative Generality - Temporary Field - Message Chains - Middle Man - Inappropriate Intimacy - Alternative Classes with Different Interfaces - Incomplete Library Class - Data Class - Refused Bequest - Comments
The concept has since become central in discussions of software craftsmanship and agile development. Identifying and resolving code smells is widely regarded as part of the continual refactoring needed to keep software healthy over time.
# See
- Code Smell - martinfowler.com
- Code smell on wikipedia ![]()