What is and for what code smell?
Code smell in software engineering point on sick code in the deep system of an software, simply is the problems that actually exist in the system but It doesn’t prevent the software from completing its tasks.
Smells are the structures in the code that not respect the fundamental design principles and negatively impact design system quality. So it’s not “BUGS”.
A code smell is a surface indication that usually corresponds to a deeper problem in the system.—Martin Fowler
Code smell: common examples
- Long methods: Most developers think the complex methods gives them the great image, but NO, do it simple and do it short. Long methods make code hard to maintain and debug.
- Duplicate Code: don’t repeat yourself!
- Lazy Class: Remember that lazy classes do the work, but in the future it’s hard to fix in bug cases.
- Dead Code: Delete it don’t just comment it or let it without doing anything. Make it clean.
Code smell tools
If we take PHP as a use case, we will found that there is a lot of tools using to do that work, some of them that listed next:
And I will come with a practical example of code smell when I have time.
Code smells can be in any system written by programmers, even experienced, so try to use code smells tools to detect the smells and try to refactoring it.