O'Reilly logo

Scala Test-Driven Development by Gaurav Sood

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Refactoring techniques

Though it's fair to say refactoring is more about common sense than a technique, there are still some very obvious refactoring techniques. The first step is to identify the code smell, which we covered in the previous section. The list is not exhaustive but just covers some frequently occurring pitfalls. Let's discuss the refactoring techniques that we can use to eliminate these code smells.

Composing methods

The majority of the code smells discussed earlier arise from within the method. The following refactoring techniques help to streamline the code and remove duplication:

  • Extract method: Whenever you see a code fragment that can be grouped together and/or does not belong in its current place, this code can be extracted into ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required