Martin Fowler’s “Refactoring: Improving the Design of Existing Code” is perhaps THE reference:
Refactoring is a controlled technique
for improving the design of an
existing code base. Its essence is
applying a series of small
behavior-preserving transformations,
each of which “too small to be worth
doing”. However the cumulative effect
of each of these transformations is
quite significant. By doing them in
small steps you reduce the risk of
introducing errors. You also avoid
having the system broken while you are
carrying out the restructuring – which
allows you to gradually refactor a
system over an extended period of
time.
Refactoring goes hand-in-hand with unit testing. Write tests before you refactor and then you have a confidence level in the refactoring (proportional to the coverage of the tests).
A good reference is: Information about Refactoring