"Refactoring is the process of modifying code without affecting
either its input or output; that is, the code's interface remains
the same. How do we know that refactoring works? The only objective
way to find the answer is by testing the code before and after
refactoring occurs. The results should match exactly. This makes
testing an integral part of any refactoring effort--you cannot
successfully separate the two.
"Some confusion exists between what it means to refactor code as
opposed to reworking it. Refactoring is a subset of reworking. If
you are making no changes to the interface of a program, you are
refactoring. If you add or change the interface, you are rewriting
the code. Strictly speaking, when you do both together, you are
rewriting. However, for political reasons, you still might want to
call it refactoring..."