HomePage | Recent changes | View source | Discuss this page | Page history | Log in |

Printable version | Disclaimers | Privacy policy

To refactor programming code is to rewrite the code, to "clean it up."

Refactoring is the process of rewriting something to improve readability and comprehension with the explicit purpose of not changing the meaning. In the case of software, a refactoring is part of the cycle of create code, test code, refactor, test code, maintain code, test code, refactor, maintain code... and so on. Testing ensures that the code does what it is supposed to. Refactoring is the part of code maintenance which doesn't fix bugs or add new functionality. Rather it is designed to improve the understandability of the code, in order to make it easier for human maintenance in the future.

An example of a simple refactoring is to change the name of a variable to something more meaningful, such as from a single letter 'i' to 'interestRate'. A more complex refactoring is to turn the code within an if block into a function. An even more complex refactoring is to replace an if conditional with polymorphism.

Many refactorings are meant to cure the ills listed in "How to Write Unmaintainable Code" [1] by Roedy Green. This is the best single reference for smelly code, I've ever seen.

The book Refactoring by Martin Fowler, in collaboration with Kent Beck, John Brant, Wililam Opdyke, and Don Roberts (ISBIN 0-201-48567-2, 1999 Addison Wesley Longman, Inc.) is the classic reference. Martin Fowler also has a website, Several good discussions are found at the WikiWeb at

To refactor text, in a WikiWiki, is to rewrite and often to reorganize the text completely or radically, sometimes dramatically shortening it, but in a way that preserves all the important, relevant content. In a WikiWiki, it is usually discussions that are refactored--with the purpose of making the discussion accessible to someone who is interested in the arguments made in the discussion, and the information to be gleaned from it, rather than the history of the discussion itself.

Obviously, refactoring is difficult to do in such a way that will make all participants in a discussion happy. It requires intelligence, tact, excellent reading comprehension skills, good writing skills, and a lack of bias.

For policy on refactoring in Wikipedia, see editing policy. In the context of Wikipedia, usually talk pages are refactored, but occasionally, when an article has been developed in a particularly haphazard way, it needs to be changed so radically that the resulting change can be called a refactoring.

Links: What Is Refactoring ( article)