Refactoring to Patterns

by Joshua Kerievsky

2004

For several years now, I've been involved with advocating agile methods in general, and Extreme Programming in particular. When I do people often question how this fits in with my long running interest in design patterns. Indeed I've heard people claim that by encouraging refactoring and evolutionary design, I'm recanting what I've previously written about analysis and design patterns.

Yet all it takes is a quick look at people to realize that this view is flawed. Look at the leading members of the patterns community and at the leading members of the agile and XP communities and you see a huge intersection. The truth is that patterns and evolutionary design have had a close relationship since their very beginnings.

Josh Kerievsky has been at the heart of this overlap. I first met him when he organized the successful patterns study groups in New York City. These groups did a collaborative study of growing literature on design patterns. I quickly learned that Josh's understanding of design patterns was second to none, and I gained a lot of insight into those patterns by listening to him. Josh adopted refactoring early, and was an extremely helpful reviewer on my book. As such it was no surprise to me that he also was a pioneer of Extreme Programming. His paper on patterns and Extreme Programming at the first XP conference is one of my favorites.

So if anyone is perfectly suited to write about the interplay of patterns and refactoring, Josh is. It's territory I explored a little bit in Refactoring, but I didn't take it too far because I wanted to concentrate on the basic refactorings. This book greatly expands that area discussing in good detail how to evolve most of the popular Gang of Four patterns, showing that they need not be designed in up front, but evolved to as a system grows.

As well as the specific knowledge about these refactorings that you can gain from studying them, this book also tells you more about patterns and refactoring in general. Many people have said they find a refactoring approach to be a better way of learning about patterns, because you see in gradual stages the interplay of problem and solution. These refactorings also reinforce the critical fact that refactoring is all about making large changes in tiny steps.

So I'm delighted to be able to present this book to you. I've spent a long time cajoling Josh to write a book, and then working with him on this one. I'm delighted with the result and I think you will be too.