List of Refactoring Techniques
Here are some examples of micro-refactorings; some of these may only apply to certain languages or language types. A longer list can be found in Fowler's Refactoring book and on Fowler's Refactoring Website. Many development environments provide automated support for these micro-refactorings. For instance, a programmer could click on the name of a variable and then select the "Encapsulate field" refactoring from a context menu. The IDE would then prompt for additional details, typically with sensible defaults and a preview of the code changes. After confirmation by the programmer it would carry out the required changes throughout the code.
- Techniques that allow for more abstraction
- Encapsulate Field – force code to access the field with getter and setter methods
- Generalize Type – create more general types to allow for more code sharing
- Replace type-checking code with State/Strategy
- Replace conditional with polymorphism
- Techniques for breaking code apart into more logical pieces
- Componentization breaks code down into reusable semantic units which present clear, well-defined, simple-to-use interfaces.
- Extract Class moves part of the code from an existing class into a new class.
- Extract Method, to turn part of a larger method into a new method. By breaking down code in smaller pieces, it is more easily understandable. This is also applicable to functions.
- Techniques for improving names and location of code
- Move Method or Move Field – move to a more appropriate Class or source file
- Rename Method or Rename Field – changing the name into a new one that better reveals its purpose
- Pull Up – in OOP, move to a superclass
- Push Down – in OOP, move to a subclass
Read more about this topic: Code Refactoring
Famous quotes containing the words list of, list and/or techniques:
“Sheathey call him Scholar Jack
Went down the list of the dead.
Officers, seamen, gunners, marines,
The crews of the gig and yawl,
The bearded man and the lad in his teens,
Carpenters, coal-passersall.”
—Joseph I. C. Clarke (18461925)
“I am opposed to writing about the private lives of living authors and psychoanalyzing them while they are alive. Criticism is getting all mixed up with a combination of the Junior F.B.I.- men, discards from Freud and Jung and a sort of Columnist peep- hole and missing laundry list school.... Every young English professor sees gold in them dirty sheets now. Imagine what they can do with the soiled sheets of four legal beds by the same writer and you can see why their tongues are slavering.”
—Ernest Hemingway (18991961)
“The techniques of opening conversation are universal. I knew long ago and rediscovered that the best way to attract attention, help, and conversation is to be lost. A man who seeing his mother starving to death on a path kicks her in the stomach to clear the way, will cheerfully devote several hours of his time giving wrong directions to a total stranger who claims to be lost.”
—John Steinbeck (19021968)