Refactoring
Development | May 23, 2010
According to Wikipedia Code refactoring is the process of changing a computer program's source code without modifying its external functional behavior in order to improve some of the nonfunctional attributes of the software.
Usually when working in a new code base, a new project or any task that involves programming, refactoring comes into play. Once the developing has started some parts stay the same whilst others change. At each step the design code should be produced with care. If the desire to keep adding new functionality under much non refactored code prevails then you have a recipe for disaster. Each time new functionality arises it will be much more painful than the last time.

In this kind of situation refactoring comes to the rescue. Identifying the repetitive methods and functions, and abstracting them into new methods or classes. Most developers should have the healthy habit of refactoring code continuously. This will be specially valuable when the time comes to maintain the code or add new functionality.
Code Refactoring has a very close friend that can't live without, which is called testing. Before starting the refactoring process there should be a full set of tests covering all the code to be refactored which can guarantee that when the refactoring is finished the code keeps on producing the same results.
When refactoring code, as well as with doing testing, there is a thin line between applying it to the although necessary amount of code, or crossing and applying to every single piece of code. Sometimes the refactored code is not enough and there are still some methods and classes repeting functionality across the code, other times the developer falls into the dark hole of refactoring too much code, which at some point of time may be wasted.
As important as balance is in life, it is also important in development too, and refactoring is not the exception. To be successful at refactoring code balance should be our north star to follow.