Chuck Connell is a software consultant, occasional academic, and writer about software engineering. He can be reached at www.BeautifulSoftware.com.
Refactoring is an incremental change to software source code, which improves the design of the program, without altering the behavior of the program.
By "design" we mean a human-readable abstraction of the software: source code, diagrams of source code, calling sequences, data flow, and broad descriptions of large software systems (architecture). By "behavior" we are referring to the semantics that matter to the program's users. Intuitively, we want the software to "do the same thing" from the users' point of view, before and after refactoring. We don't care if the modified source code causes the compiler to generate different machine code.
A simple example of refactoring is Split Temporary Variable. This change is applied to a variable that has been reused for more than one purpose, and splits it into two or more variables, each with a single, clear use. The new variables are easier to understand and debug because each has only one meaning. After this refactoring, the program has a better design and is more readable.