Copyright © Philip M. Parker, INSEAD. Terms of Use.

REFACTORING

Specialty Definition: REFACTORING

DomainDefinition

Computing

Refactoring Improving a computer program by reorganising its internal structure without altering its external behaviour. When software developers add new features to a program, the code degrades because the original program was not designed with the extra features in mind. This problem could be solved by either rewriting the existing code or working around the problems which arise when adding the new features. Redesigning a program is extra work, but not doing so would create a program which is more complicated than it needs to be. Refactoring is a collection of techniques which have been designed to provide an alternative to the two situations mentioned above. The techniques enable programmers to restructure code so that the design of a program is clearer. It also allows programmers to extract reusable components, streamline a program, and make additions to the program easier to implement. Refactoring is usually done by renaming methods, moving fields from one class to another, and moving code into a separate method. Although it is done using small and simple steps, refactoring a program will vastly improve its design and structure, making it easier to maintain and leading to more robust code. "Refactoring, Reuse & Reality" by Bill Opdyke (http://st-www.cs.uiuc.edu/users/opdyke/wfo.990201.refac.html). "Refactoring, a first example" by Martin Fowler (http://www.aw.com/cseng/titles/0-201-89542-0/vidrefact/vidrefact.html). (2001-05-02). Source: The Free On-line Dictionary of Computing.

Source: compiled by the editor from various references; see credits.

Top     

Specialty Definition: Refactoring

(From Wikipedia, the free Encyclopedia)

Refactoring is the process of rewriting written material to improve its readability or structure, with the explicit purpose of keeping its meaning or behavior.

Refactoring Code

The term refactoring is often used to describe modifying source 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 still 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 and design, 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.

The term is by analogy with the factorization of numbers and polynomials. For example, can be factored as , revealing an internal structure that was previously not visible (such as the two zeroes at +1 and -1). Similarly, in software refactoring, the change in visible structure can often reveal the "hidden" internal structure of the original code.

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 new aspect is explicitly wanting to improve an existing design without altering its intent or behavior.

Refactoring is an important aspect of extreme programming.

The book Refactoring [1] is the classic reference. Although refactoring code has been done informally for years, William F. Opdyke's 1993 PhD dissertation [4] 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 [5].

Break down large functions

Functions that grow in use also grow in size. After a certain point, it becomes clear that functions can benefit from using functions themselves. Your eyes probe the function looking for a likely candidate to relocate elsewhere. This candidate is chosen for being the largest stretch of code that really has nothing to do with the enclosing function. This lets us easily think up a name that explains what the new function does without having to resort to something contrived just to distinguish it from the original function.

This section is originally from Perl Design Patterns Book

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 Wikipedia

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 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.

External links and bibliography

  1. Martin Fowler, Refactoring. Improving the Design of Existing Code, Addison-Wesley Professional 1999, ISBN 0201485672
  2. What Is Refactoring (c2.com article)
  3. http://www.refactoring.com is Martin Fowlers homepage about refactoring.
  4. William F. Opdyke's 1993 PhD dissertation at ftp://st.cs.uiuc.edu/pub/papers/refactoring/opdyke-thesis.ps.Z
  5. "How to Write Unmaintainable Code" [1] by Roedy Green

Source: adapted by the editor from Wikipedia, the free encyclopedia under a copyleft GNU Free Documentation License (GFDL) from the article "Refactoring."

Top     

Frequency of Internet Keywords: REFACTORING

The following statistics estimate the number of searches per day across the major English-language search engines as identified by various trade publications. Hyperlinks lead to commercial use of the expression at Amazon.com.
 
ExpressionFrequency
per Day

refactoring

13
Source: compiled by the editor from various references; see credits.

Top     

Anagrams: REFACTORING

Scrabble® Enable2K-Verified Anagrams

Words within the letters "a-c-e-f-g-i-n-o-r-r-t"

-1 letter: refracting, refraction.

-2 letters: cratering, factoring, fornicate, recrating, retracing, terracing.

-3 letters: anoretic, anterior, argentic, carrotin, catering, craftier, crafting, creating, creation, faceting, fraction, frontage, frontier, gerontic, infector, orangier, reacting, reaction, refacing, tricorne.

-4 letters: aconite, acrogen, anergic, angrier, argotic, carotin, carrion, carting, ceratin, certain, cigaret, cirrate, coagent, coating, cognate, coinage, coinfer, cointer, conifer, coreign, cornier, crating, creatin.

 Words containing the letters "a-c-e-f-g-i-n-o-r-r-t"
 

+2 letters: ferromagnetic.

 

+3 letters: cotransferring.

 

+4 letters: reconfiguration.

 

+5 letters: reconfigurations.

Source: compiled by the editor from various references; see credits.

SCRABBLE® is a registered trademark. All intellectual property rights in and to the game are owned in the U.S.A and Canada by Hasbro Inc., and throughout the rest of the world by J.W. Spear & Sons Limited of Maidenhead, Berkshire, England, a subsidiary of Mattel Inc. Mattel and Spear are not affiliated with Hasbro.

Top     

Alternative Orthography: REFACTORING


Hexadecimal (or equivalents, 770AD-1900s) (references)

52 45 46 41 43 54 4F 52 49 4E 47

Leonardo da Vinci (1452-1519; backwards) (references)

American Sign Language (origins from 1620-1817 in Italy and, especially, France) (references)

=

Semaphore (1791, in France) (references)

Braille (1829, in France) (references)

Morse Code (1836) (references)

.-.    .    ..-.    .-    -.-.    -    ---    .-.    ..    -.    --.

Dancing Men (Sir Arthur Conan Doyle, 1903) (references)

Binary Code (1918-1938, probably earlier) (references)

01010010 01000101 01000110 01000001 01000011 01010100 01001111 01010010 01001001 01001110 01000111

HTML Code (1990) (references)

&#82 &#69 &#70 &#65 &#67 &#84 &#79 &#82 &#73 &#78 &#71

ISO 10646 (1991-1993) (references)

0052 0045 0046 0041 0043 0054 004F 0052 0049 004E 0047

British Sign Language (Fingerspelling, BSL; 1992, British Deaf Association Dictionary of British Sign Language) (references)

Encryption (beginner's substitution cypher): (references)

5239403537544952434841

Top     



INDEX

1. Expressions: Internet
2. Anagrams
3. Orthography
4. Bibliography


  

Copyright © Philip M. Parker, INSEAD. Terms of Use.