“Dirty code” can be summarized as laziness, incompetence or just good old fashioned ignorance. When it starts to become a habit, code can become unmanageable, confusing and of a lesser quality.
Code refactoring can be described as the process of restructuring computer code making it easier to read and understand. You want to do this without changing any of the external behaviors that you intend the program to perform. Clean code and a simple design is the goal.
This can be thought of as a systematic process of improving existing code. You want the code to increase in quality for the benefit of the final product. We’ve all heard the saying: “Cleanliness is next to Godliness”!
Steps to refactoring:
- Start at the beginning of your code
- Complete refactoring one step at a time
- Run a test after each change
- Save changes
- Continue the process repeating steps 2-4