Revision as of 03:02, 29 March 2003 editDwheeler (talk | contribs)Extended confirmed users2,916 edits Noted William F. Opdyke's 1993 PhD dissertation, minor improvements.← Previous edit | Revision as of 18:55, 29 March 2003 edit undoDwheeler (talk | contribs)Extended confirmed users2,916 edits Refactored the refactoring page (discussing programming, then general text). Added more links.Next edit → | ||
Line 1: | Line 1: | ||
<b>Refactoring</b> is the process of rewriting written material | |||
To <b>refactor</b> programming ] is to rewrite the code, to "clean it up." | |||
to its improve readability or structure, with the explicit purpose of not changing its meaning or behavior. | |||
== Refactoring Code == | |||
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 or | |||
change its structure, in order to make it easier for human maintenance | |||
in the future. | |||
The term refactoring is often used to describe modifying programming ] | |||
⚫ | An example of a |
||
without changing its external behavior, and is sometimes informally | |||
referred to as "cleaning it up." | |||
In this case, refactoring is part of the cycle of create and test code, | |||
refactor and test code, add new behavior and test code, refactor and test code, add new behavior and test 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 or change its structure, to make it easier for human maintenance in the future. In particular, adding new behavior to a program might be difficult with the program's given structure, so a developer might refactor it first to make easy, and then add the new behavior. | |||
Refactoring is done as a separate step, to simplify testing: at the end of the refactoring, any change in behavior is clearly a bug and can be fixed separately from the problem of debugging the new behavior. | |||
⚫ | An example of a trivial refactoring is to change a variable name into 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. While "cleaning up" code has happened for decades, the key insight in refactoring is to intentionally "clean up" code separately from adding | ||
⚫ | Many refactorings are meant to cure the ills listed in "How to Write Unmaintainable Code" by ]. | ||
new functionality, using a known catalogue of common useful refactoring methods, and then separately testing the code (knowing that any behavioral changes | |||
indicate a bug). | |||
The book <b>Refactoring</b> by ], in collaboration with ], ], ], and ] (ISBN 0-201-48567-2, 1999 Addison Wesley Longman, Inc.) is the classic reference. Martin Fowler also has a website, http://www.refactoring.com |
The book <b>Refactoring</b> by ], in collaboration with ], ], ], and ] (ISBN 0-201-48567-2, 1999 Addison Wesley Longman, Inc.) is the classic reference. Martin Fowler also has a website, http://www.refactoring.com. | ||
Although refactoring code has been done informally for years, | Although refactoring code has been done informally for years, | ||
is the first known paper to specifically | is the first known paper to specifically | ||
examine refactoring |
examine refactoring. | ||
All of these resources provide a catalog of common methods for | |||
expressly describing why refactoring is a useful technique. | |||
refactoring; a refactoring method has a description of how to | |||
apply the method and | |||
indicators for when you should (or should not) apply the method. | |||
Refactoring is such an important concept that it has been identified as | |||
⚫ | Many refactorings are meant to cure the ills listed in "How to Write Unmaintainable Code" by ]. | ||
== Refactoring other Text == | |||
The term refactoring originated in computer programming, but the concept | |||
has also been applied when modifying any text. | |||
To <b>refactor</b> 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 <nowiki>WikiWiki</nowiki>, 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. | To <b>refactor</b> 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 <nowiki>WikiWiki</nowiki>, 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 ], tact, excellent reading comprehension skills, good writing skills, and a lack of bias. | Obviously, refactoring is difficult to do in such a way that will make all participants in a discussion happy. It requires ], tact, excellent reading comprehension skills, good writing skills, and a lack of bias. | ||
Several good discussions are found at the WikiWeb at . | |||
---- | ---- |
Revision as of 18:55, 29 March 2003
Refactoring is the process of rewriting written material to its improve readability or structure, with the explicit purpose of not changing its meaning or behavior.
Refactoring Code
The term refactoring is often used to describe modifying programming code without changing its external behavior, and is sometimes informally referred to as "cleaning it up." In this case, refactoring is part of the cycle of create and test code, refactor and test code, add new behavior and test code, refactor and test code, add new behavior and test 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 or change its structure, to make it easier for human maintenance in the future. In particular, adding new behavior to a program might be difficult with the program's given structure, so a developer might refactor it first to make easy, and then add the new behavior. Refactoring is done as a separate step, to simplify testing: at the end of the refactoring, any change in behavior is clearly a bug and can be fixed separately from the problem of debugging the new behavior.
An example of a trivial refactoring is to change a variable name into 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. While "cleaning up" code has happened for decades, the key insight in refactoring is to intentionally "clean up" code separately from adding new functionality, using a known catalogue of common useful refactoring methods, and then separately testing the code (knowing that any behavioral changes indicate a bug).
The book Refactoring by Martin Fowler, in collaboration with Kent Beck, John Brant, William Opdyke, and Don Roberts (ISBN 0-201-48567-2, 1999 Addison Wesley Longman, Inc.) is the classic reference. Martin Fowler also has a website, http://www.refactoring.com. Although refactoring code has been done informally for years, William F. Opdyke's 1993 PhD dissertation is the first known paper to specifically examine refactoring. All of these resources provide a catalog of common methods for refactoring; a refactoring method has a description of how to apply the method and indicators for when you should (or should not) apply the method.
Refactoring is such an important concept that it has been identified as one of the most important software innovations.
Many refactorings are meant to cure the ills listed in "How to Write Unmaintainable Code" by Roedy Green.
Refactoring other Text
The term refactoring originated in computer programming, but the concept has also been applied when modifying any text.
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. Refactoring is critically important process in developing and maintaining the Misplaced Pages.
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.
Several good discussions are found at the WikiWeb at c2.org.
For policy on refactoring in Misplaced Pages, see editing policy. In the context of Misplaced Pages, 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.
External Links: