The article “Pattern & XP” is written by Joshua Kerievsky. The purpose of this article is to figure out how to apply Patterns to the context of Extreme Programming, because he thinks that XP has far focused heavily on Refactoring while remaining all but silent about Patterns, the reason for this is that Patterns encourage over-engineering, while Refactoring keeps things simple and light.
The prerequisite of understanding the importance of combining patterns and refactoring is realizing the relationship between them. This article has quoted some words from the Design Patterns Book, which can help to explain it well.
Our design patterns capture many of the structures that result from refactoring. Using these patterns early in the life of a design prevents later refactorings. But even if you don’t see how to apply a pattern until after you’ve built your system, the pattern can still show you how to change it. Design patterns thus provide targets for your refactoring.
However, there are two problems of applying patterns early in the life of a design. The first one is over-engineering, which means that we make great efforts to produce flexible and robust designs early in the life of a system, but we do not realize that all our work will be meaningless and wasteful if the system never needs such degrees of flexibility and robutness. Sometimes, it is not necessary to inject various desgin patterns to our designs. Secondly, there is no 100% perfect design, in order to keep the system in high quality, refactorying is necessary!
In the other side, without Patterns, refactoring may make small design improvements, but their overall design will ultimately suffer because it lacks the order, simplicity, and effectiveness that come from intelligently using Patterns.
Herefore, Joshua Kerievsky suggest us that: start simple, think about Patterns but keep them on the back-burner, make small refactorings, and move these refactorings towards a Pattern or Patterns only when there is a genuine need for them.