Code Smell
Surface-level indicators in source code that suggest deeper problems in the design or implementation.
Also known as: Bad Code Smell, Design Smell
Category: Software Development
Tags: code-quality, refactoring, software-engineering, programming, best-practices
Explanation
A Code Smell is a surface indication in source code that usually corresponds to a deeper problem in the system. The term was popularized by Martin Fowler and Kent Beck. Code smells are not bugs—the code works—but they indicate weaknesses that may slow development or increase the risk of bugs. Common code smells include: (1) Long methods - functions doing too much, (2) Large classes - classes with too many responsibilities, (3) Feature envy - methods using other classes' data excessively, (4) Duplicate code - repeated logic across the codebase, (5) Dead code - unused code that remains, (6) Magic numbers - unexplained literal values, (7) Shotgun surgery - changes requiring edits in many places. Recognizing code smells is a key skill for maintaining code quality. The remedy is usually refactoring—restructuring code without changing its behavior.
Related Concepts
← Back to all concepts