🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

Programming Concepts Beginner

What is Code Smell?

A surface indication in code that usually corresponds to a deeper problem in the system, suggesting the need for refactoring.

Code smells are not bugs — the code works correctly — but they indicate design weaknesses that may cause problems over time. Common smells include: Long Method (functions doing too much), God Class (a class that knows too much), Feature Envy (a method that uses another class's data more than its own), Primitive Obsession (using primitives instead of small objects), Shotgun Surgery (a change requires modifying many classes), and Duplicate Code. Martin Fowler's refactoring catalog provides specific techniques for addressing each smell. Static analysis tools (SonarQube, PHPStan) can detect certain code smells automatically.

Related Terms

Design Pattern
A reusable solution template for commonly occurring problems in software design.
Event-Driven Architecture
A software design pattern where components communicate by producing and consuming events rather than direct method calls.
Linked List
A linear data structure where elements are stored in nodes, each containing data and a pointer to the next node in the sequence.
Composition over Inheritance
A design principle favoring object composition (has-a relationships) over class inheritance (is-a relationships) for code reuse.
Hash Table
A data structure that maps keys to values using a hash function, providing average O(1) time complexity for lookups, insertions, and deletions.
SOLID Principles
Five design principles for writing maintainable, flexible object-oriented code: Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion.
View All Programming Concepts Terms →