List of Refactorings

  • “Any fool can write code that a computer can understand. Good programmers write code that humans can understand.”
    —M. Fowler (1999)
Refactoring

Refactoring is improving the design of existing code. The first step in coding is getting code that works, but do not stop there. The next step is making your code clear and maintainable, and that is what refactoring helps you do. Since refactoring is changing code, you should have unit tests for your code base before you refactor so you can make sure you are not breaking code.

Here is a list of all the posts we have for refactoring. Some refactorings are simple, some are more complex; however, refactoring is considered an essential skill for competent programmers so you should learn them and use them. You will write better code once you start using refactoring.

  • Extract Method
    Break long methods into shorter methods.
  • Inline Method
    Inline a simple method when the body is as clear as the name.
  • Inline Variable
    Use a simple expression directly when a variable does not add any clarity or value.
  • Introduce Explaining Variable
    Store the result of an expression in a variable with a name that explains its purpose.
  • Introduce Parameter Object
    Create a class for commonly used groups of parameters.
  • Remove Dead Code
    Remove code that is no longer used.
  • Rename Variable
    Rename a variable so that its name clearly indicates its purpose.
  • Split Temporary Variable
    Make separate temporary variables for each assignment.
Scroll to Top