Refactored - List of Refactoring Techniques

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:  Refactored

Famous quotes containing the words list of, list and/or techniques:

    Shea—they 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-passers—all.
    Joseph I. C. Clarke (1846–1925)

    Lastly, his tomb
    Shall list and founder in the troughs of grass
    And none shall speak his name.
    Karl Shapiro (b. 1913)

    It is easy to lose confidence in our natural ability to raise children. The true techniques for raising children are simple: Be with them, play with them, talk to them. You are not squandering their time no matter what the latest child development books say about “purposeful play” and “cognitive learning skills.”
    Neil Kurshan (20th century)