Home > Articles > Programming

  • Print
  • + Share This
This chapter is from the book


Refactoring is the technique of improving code without changing functionality. Refactoring is an ongoing process of simplification that applies to code, design, testing, and XP itself. Rather than just saying "you should keep trying to make your code better," you will need a repeatable process to guide refactoring. In some ways, you've always done some form of refactoring as you review your code and make changes and improvements. The problem is that it's haphazard and is left until the team has spare time. In XP, developers will be refactoring during the entire process of development.


The standard reference on refactoring is Martin Fowler's Refactoring: Improving the Design of Existing Code.

Why refactor? Because you're an XP developer it means that your code should be the simplest thing that could possibly work. Inevitably, your initial code might tend to be overly complex which is true even of a 20-line function. We learned early on in this book how software is a craft more than a science, and you constantly cycle through code-run-refine as you go along. Refactoring has given your simplifying, improving process a name. In Hour 21, "More on Refactoring Techniques," we will cover examples of specific refactorings you can use; skip to that chapter now if you want to get a head start today with refactoring.

  • + Share This
  • 🔖 Save To Your Account