refactoring

refactoring

(object-oriented, programming)Improving a computer programby reorganising its internal structure without altering itsexternal behaviour.

When software developers add new features to a program, thecode degrades because the original program was not designedwith the extra features in mind.

This problem could be solved by either rewriting the existingcode or working around the problems which arise when addingthe new features. Redesigning a program is extra work, butnot doing so would create a program which is more complicatedthan it needs to be. Refactoring is a collection oftechniques which have been designed to provide an alternativeto the two situations mentioned above.

The techniques enable programmers to restructure code sothat the design of a program is clearer. It also allowsprogrammers to extract reusable components, streamline aprogram, and make additions to the program easier toimplement.

Refactoring is usually done by renaming methods, movingfields from one class to another, and moving code into aseparate method.

Although it is done using small and simple steps,refactoring a program will vastly improve its design andstructure, making it easier to maintain and leading tomore robust code.

"Refactoring, Reuse & Reality" by Bill Opdyke.

"Refactoring, a first example" by Martin Fowler.