O'Reilly logo

Test-Driven Development with Mockito by Sujoy Acharya

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

Chapter 2. Refactoring – Roll the Dice

Refactoring is restructuring code to improve readability, maintainability, and extensibility.

In this chapter we will look at the following topics:

  • Definition of refactoring
  • Refactoring examples
  • Code smells
  • Starting and stopping refactoring

Refactoring

Refactoring is a series of small steps to change the internal structure of code without altering its external behavior. Refactoring is applied to make the code readable, maintainable, and clean.

Reasons behind refactoring

Refactoring is required to achieve the following points:

  • Easy to add new features/code: Design erodes very quickly. Developers add features and hack the design to accomplish short-term goals. Refactoring helps in maintaining the design.
  • Improves the ...

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