Hi there,

this week we got an interesting task to train our refactoring skills. This task was taken from the first chapter of Martin Fowlers book ‘Refactoring.’ Starting from this code the task is to enhance the code by following the individual steps described by Fowler.

You can observe the results of our three team members in the repos below:

Many refactoring steps that are described in the book can actually be done by your IDE instead of performing them manually. Following, we will demonstrate you some of them in IntelliJ IDEA:

The rename action can even suggest some sane names for variables to you, pretty cool.

With move instance method you can move a method to another class, when it is more suited to be part of that class.

The action inline variable allows you to remove a temporary variable and instead compute the values everytime the variable was used.

Safe delete represents an effective IDE action because it can search in the entire project for usages and even in comments and strings, making sure you don’t delete anything that you eventually still needed.

Type migration allows you to modify the type of variables, but most of the time you probably have to clean up after performing this.

That’s it for this blogpost, have a nice day!