๐ŸŽ 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

Race Condition
A bug that occurs when the behavior of software depends on the timing or order of uncontrolled events like thread scheduling.
Memoization
An optimization technique that caches function results for given inputs, avoiding redundant computations for repeated calls.
DRY (Don't Repeat Yourself)
A software development principle that aims to reduce code duplication by abstracting common patterns into reusable components.
Twelve-Factor App
A methodology of twelve best practices for building modern, scalable, maintainable software-as-a-service applications.
Singleton Pattern
A design pattern that restricts a class to a single instance and provides a global point of access to that instance.
Binary Search
An efficient search algorithm that finds a target value in a sorted array by repeatedly dividing the search interval in half.
View All Programming Concepts Terms โ†’