
139
Chapter 9
Refactoring
Objectives
Refactoring is a phase of software change that improves the structure of the soft-
ware while keeping the same functionality; the software has the same behavior
before and after the refactoring. In this chapter, you will learn when and how to
refactor the code so that evolution can continue unhindered.
After you have read this chapter, you will know:
◾ Prefactoring, which prepares the code for a specific change
◾ Postfactoring, which removes bad smells from the code
◾ Several specific refactorings, including function extraction, base class extrac-
tion, and component class extraction
***
An introductory example of ...