Refactoring is a technique where you changes existing code without changing the external behavior. Continues refactoring and improving code design makes the code cleaner and it´s easy to accumulate technical debt and refactoring is a great way to repay that debt.
Some advantages with refactoring is that it can reduce complicity, fixing bugs, improve maintainability, make the code design modern and easier to work with.
Best way is to “refactor” in many small changes, that over time accumulate to bigger changes and great positive effects. Small changes is a way to try to avoiding introducing new bugs when refactoring/redesigning the code.
Don´t skip this part in the development process, technical debt will rise fast if you don’t take care of the code and clean it. So try to plan ahead for refactoring or you will get what is called for “bad code smells”.
Some causes to bad code smells:
Code, methods and classes that have grown to big that there are hard to work with.
Is something that are unnecessarily and can be deleted without any effect on external behaviors.
- Change Preventers
Is when there are too many dependencies so when you need to change something you need to make the same changes in other places too.
- Code Smells
- Wikipedia, Code Smells
- Wikipedia, refactoring
- Improving the Design of Existing Code – Martin Fowler