Chapter 4. Refactor Mercilessly

Refactoring your code is a continuous process. It should not be limited to just the application code. In this chapter we will cover:

  • Clean code
  • Red-Green-Refactor
  • Code smell
  • To refactor or not to refactor?
  • Refactoring techniques
  • Building reusable test code

Clean code

We have been harping on about clean code for a while now. Let's take a moment to define what exactly clean code is.

Very simply put, clean code is simple code: no gimmicks, no short cuts, and easy to understand. It should pass all the tests and should not have any duplication. It contains the minimum number of moving parts.

Get Scala Test-Driven Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.