Chapter 3. Refactoring in small steps

 

The most powerful designs are always the result of a continuous process of simplification and refinement.

Kevin Mullet, Designing Visual Interfaces: Communication Oriented Techniques

In the previous chapter, we began implementing a template engine using test-driven development, starting from basically nothing and ending up with a rather useful chunk of code. In fact, we’ve gotten this far with almost laughably little code. If you look at our Template class, it’s a lot smaller than I suppose most would’ve guessed based on years of experience in waterfall-style, big-design-up-front development. Or maybe it’s just me. Perhaps others have indeed come up with small and simple solutions while I devised fancy and complex designs.

We did bump into a problem, however, with our use of regular expressions to scan the template text for variables. I like to think of these kinds of obstacles as opportunities to make design decisions. A lot of the time while developing test-first, the steps we take are relatively trivial, obvious even. It’s refreshing when the going gets rough for a while and we need to stretch our imagination to figure out how to solve the problem. In this chapter, we’ll learn to make a big change in our design in small steps and in a controlled manner.

3.1. Exploring a potential solution

 
 
 

3.2. Changing design in a controlled manner

 
 
 

3.3. Taking the new design further

 
 
 

3.4. Summary

 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest