What is a "code smell" and how does it relate to SOLID?
Answer
A code smell is a surface indication in the code that something may be wrong with the underlying design — it doesn't necessarily mean there's a bug, but it suggests a potential problem worth investigating. Code smells often indicate SOLID violations: a God Class (class that does everything) violates SRP; a class that requires modification every time a new feature is added violates OCP; an interface with many methods that most implementors leave empty violates ISP; classes that directly instantiate their dependencies violate DIP. Common code smells include long methods, large classes, duplicate code, long parameter lists, and inappropriate intimacy. Recognizing these smells is the first step toward applying SOLID principles as a refactoring guide.
Previous
Why are SOLID principles important in software development?
Next
Give an example of SRP violation.