In this chapter, we looked at refactoring and examined how it is applied in XP. Even outside XP, refactoring is a useful tool. Inside XP, refactoring is an integral part of emergent design.
We explore refactoring as used in emergent design in Chapter 12.
Refactoring by itself is useful for correcting or improving a design, though constant refactoring is expensive. Refactoring a database is even more expensive, because the database tends to drive the entire application (though the code can be shielded to an extent). Recognizing this fact is an important first step toward recognizing the importance of spending extra time trying to get the design right (particularly the database design) up front.
One of the reasons why refactoring and emergent design play such a large part in XP is that the project is designed only for the current iteration. Any attempt to design ahead is met with a cry of YAGNI!
In each iteration, the functionality to be added is defined by user stories, which we cover in the next chapter.