๐ŸŽ New User? Get 20% off your first purchase with code NEWUSER20 ยท โšก Instant download ยท ๐Ÿ”’ Secure checkout 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

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.
Unit Testing
Testing individual components or functions of a program in isolation to verify they work correctly.
Queue
A data structure that follows First-In-First-Out (FIFO) ordering, where elements are added at the rear and removed from the front.
Functional Programming
A programming paradigm that treats computation as the evaluation of mathematical functions, avoiding state changes and mutable data.
Stack
A data structure that follows Last-In-First-Out (LIFO) ordering, where elements are added and removed from the same end (top).
Version Control
A system that records changes to files over time, allowing you to recall specific versions, collaborate, and track history.
View All Programming Concepts Terms โ†’