Not necessarily wrong code, but shit code that impacts maintainability.
Code Duplication
- Useful pieces of code are copy-pasted throughout the codebase. This is by far the most common code smell among new programmers. It causes a maintenance nightmare: a bug fix in one place must be propagated to all duplicated places.
- Solution: use an abstraction technique (e.g., extract a method, use inheritance) to remove the duplication.
Multiple Personality Class
- A class that contains disjoint sets of public methods used by disjoint sets of clients, making its purpose hard to understand.
- Solution: refactor each set of methods into its own class.
The Blob
- A large class that lacks cohesion or makes most of the processing decisions.
- Solution: refactor into a series of more cohesive, focused classes.
Data Class
- A class that exposes data members but provides no substantial functionality; data is manipulated elsewhere. Related data and behaviour are not in the same scope (poor proximity), leading to fragile design.
- Solution: move methods that manipulate the data into the data class itself. (interesting take tbh)
Data Clump
- A large group of parameters that appear together in the signatures of many methods.
- Solution: introduce a new class that encapsulates the parameter group.
Feature Envy
- A method that manipulates the data of another class more than its own.
- Solution: move the method to the class whose data it uses.
Tradition Breaker
- A subclass breaks the API inherited from its superclass by overriding methods with empty implementations or reducing visibility.
- Solution: redesign the inheritance structure so that the subclass properly substitutes for its superclass.