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

To refactor or not to refactor

There is no such thing as too much refactoring, but there are stages in the development process that act as an impetus for refactoring. Here are a few of them.

Doing it thrice (rule of three)

When you do something the first time, you just do it to get it done. When doing the same thing a second time, you do the same thing again, though you squirm at having to repeat it. When you do it a third time, you start refactoring.

Adding new feature

When you are adding a new feature to someone else's unclear code, it is better to start refactoring it before adding the feature. Refactoring helps you understand the unclear code. Refactored code facilitates the smooth addition of new features.

Bug fixing

Bugs normally live in smelly ...

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