Long ago, I thought refactoring of code was something to be done only when you had free time and was really less busy at work. I considered it an activity to be done later when everything about a program has been done. But lately, I have come to realize that there is a mistake in having such assumptions about refactoring.
Refactoring is not always an urgent task but be careful for it is indeed an important task. You need to always refactor your code. Refactoring your code is like clearing your garden. It is not always an urgent activity but it sure is an important one.
A code is simply good if it contains no bad code. But it is highly impossible to write code that would not contain one or two bad code attached to it. It is your job as a Software Developer to from time to time clear out the bad code. It makes your code even cleaner that it was when you met it.
Refactoring of code allows you to add a new idea to how a problem was initially solved. It creates a better environment for writing more clean and clear code. It allows to have a culture of cleaning and making things better than we initially met them.
But be careful about refactoring code because if done wrongly could make the system worse that it was before. So before you decide to refactor a code, ensure that you fully understand how the system currently works and how you would like to change the system.
Because it is easier to make something worse than better, refactoring is indeed not an easy task. Refactoring is about doing or making something better. Being good should not be the goal, becoming better should be. So is the same for your code. Your code can run fine and seems to have no problems at all, but can it be made better.
A code should be regularly refactored. This makes the core concept of the code more understandable than it was when the code was initially written. It takes out old ideas and flushes in new ideas of writing code.
Find time out of your very busy schedule to refactor your code. It might not make any immediate business idea. But in the long run, it pays to refactor your code.