11.2: Refactorings

Object-Oriented Reengineering Patterns · LibreTexts

0%

Contents

    Text

    Size
    100%
    Theme
    Typeface
    Line length
    Spacing

    From LibreTexts, under CC BY-SA, as the source states it; its equations are written in TeX, which the PDF shows typeset. This page at LibreTexts.

    11.2: Refactorings

    Encapsulate Field

    Also Known As: Abstract Instance Variable [Rob99].

    Intent There is a public field. Make it private and provide accessors.

    Source: Refactoring: Improving the Design of Existing Code [FBB+99].

    Referenced from: Eliminate Navigation Code.

    Extract Method

    Intent You have a code fragment that can be grouped together. Turn the fragment into a method whose name explains the purpose of the method.

    Source: Refactoring: Improving the Design of Existing Code [FBB+99].

    Referenced from: Refactor to Understand, Visualize Code as Dotplots, Move Behavior Close to Data.

    Move Method

    Intent A method is, or will be, using or used by more features of another class than the class on which it is defined. Create a new method with a similar body in the class it uses most. Either turn the old method into a simple delegation, or remove it altogether.

    Source: Refactoring: Improving the Design of Existing Code [FBB+99].

    Referenced from: Refactor to Understand, Move Behavior Close to Data.

    Rename Attribute

    Intent Rename an instance variable and update all references to it.

    Source: Practical Analysis for Refactoring [Rob99].

    Referenced from: Refactor to Understand.

    Rename Method

    Intent The name of a method does not reveal its purpose. Change the name of the method.

    Source: Refactoring: Improving the Design of Existing Code [FBB+99].

    Referenced from: Refactor to Understand.

    Replace Conditional with Polymorphism

    Intent You have a conditional that chooses different behavior depending on the type of an object. Move each leg of the conditional to an overriding method in a subclass. Make the original method abstract.

    Source: Refactoring: Improving the Design of Existing Code [FBB+99].

    Referenced from: Transform Client Type Checks.


    This page titled 11.2: Refactorings was last modified on Tue, 01 Dec 2020 03:50:37 GMT and is shared under a CC BY-SA license and was authored, remixed, and/or curated by Serge Demeyer, Stéphane Ducasse, Oscar Nierstrasz.