IntelliJ IDEA
 
Get IntelliJ IDEA
You are viewing the documentation for an earlier version of IntelliJ IDEA.

Introduction to refactoring

Last modified: 11 February 2024

IntelliJ IDEA offers a lot of automatic refactoring capabilities, but as developers it is not enough to know how to perform them, we need to understand what these refactorings are, when we would want to apply them, and any possible downsides or things to consider before using them.

Refactoring, as defined by Martin Fowler, "...is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior". Hence, it is important before performing any refactoring in production code to have comprehensive test coverage to prove that you haven't inadvertently changed the behaviour.

The goal of this tutorial is to introduce those who may be new to the idea of refactoring, particularly automatic refactoring, to IntelliJ IDEA's capabilities and show when you might want to apply three of the basic types of refactoring: Renaming, Extracting and Deleting.