Swiss Cheese and Pair Programming

Explaining the benefits of pair programming to someone new to the concept can be difficult, particularly when that person has the initial, understandable, reaction that they’ll be paying two developers to do the work of one—why would they want to do that?

Swiss cheese stacked on a plate

But recently, on one of my favorite podcasts (The Skeptics’ Guide to the Universe), I heard an interesting dairy-based metaphor for how experts can work together to solve problems that one alone cannot. It provided a unique way of looking at the issue—one I think can quickly and effectively show how pair programming can be leveraged as a tool to help build the highest-quality software.

Swiss Efficiency

The Swiss Cheese model is well established in risk management circles. It’s a good way to illustrate defense in depth for matters of security, but I hadn’t thought of it in terms of people before. Applied to software developers and software development, it works like this:

Two sandwiches with one slice of Swiss cheese each

Imagine two sandwiches like the one in the picture, each with a single slice of cheese. Sandwiches are tasks in our metaphor, and a slice of cheese represents a software developer, like myself. We’re each working on our own task, and at first blush, our output looks efficient because we’re tackling two tasks in parallel.

Unfortunately, due to our weaknesses (the holes in the cheese), we are incompletely covering the sandwich—you can see plenty of pastrami peeking through the holes in the cheese. Some bites will be reasonably cheesy, but some will be uncomfortably low on cheese content. I don’t know about you, but if I’m going to have a pastrami and Swiss sandwich, I want to taste that Swiss cheese.

Pairing Up

Now let’s try a different way of configuring our cheese slices.

One sandwich with two slices of Swiss cheese

By stacking the two slices together, we can provide much more complete coverage by the cheese. Each slice by itself still has all its holes, but because the slices are different and have holes in different places, the amount of exposed pastrami is dramatically reduced—together, the slices of cheese cover more area than one slice alone ever could.

Similarly, in pair programming, two software developers working together on a task can fill in for each other’s weaknesses. Even the most experienced developers have weaknesses—knowing those weaknesses is often a useful measure of how experienced a developer is. The best pairs complement each other, and (wholly unlike cheese—all metaphors must break at some point) learn from each other.

Working together, they make better software, with less risk that it must be revisited. The result is software—much like our sandwich—that is more likely to satisfy.