2. Code Smell are certain structures in the code that indicate violation of
fundamental design principles and negatively impact design quality.
Refactoring is a disciplined technique for restructuring an existing body of code,
altering its internal structure without changing its external behavior.
3. “A code smell is a surface indication that usually
corresponds to a deeper problem in the system”
- Martin Flower
4. Design Principles
Every OO Designer should have follow below design principle, failing to that leads to
code smells in your software.
Design Principles:
- Single Responsibility
- Open Close principle
- Interface Segregation
- Dependency Inversion principle
- Liskov Substitution principle
5. Levels of Code smell
There are three levels of
code smell:
1. Method level
2. Class level
3. Application level
6. Bad smells in a code
Long Method
- Extract method
Long class
- Extract Class
Long parameter list
- Introduce Object parameter
Primitive Obsession
- Introduce Object parameter
Duplicate Code (Don’t Repeat Yourself)
- Create Template method