Pair programming

Most of the last few employers I’ve worked for have been somewhat leery of the concept of pair programming. After all, you have two (or perhaps more) programmers working on a single bit of code, obviously you’re getting half as much work done, right? Some of them (including, I think, my current one) are somewhat tolerant of it, because they see that stuff actually gets done. But I certainly understand the wariness that they feel when they see two programmers crouched around one screen yelling at each other. 😉

Well, for the last week – almost two weeks, in fact – I’ve been wrestling with the same bit of code, trying to implement the same feature. I knew it couldn’t possibly be that hard, but everything felt just wrong.

Today Chris and I worked through some of these issues, argued about implementations, brainstormed about various solutions, and ended up ripping out a piece of the code that, while it kinda looked ok, had been making me feel gradually more uncomfortable for the last few weeks, and turned out to be squarely in the way of what we were trying to accomplish.

And, as a result, we now have a simple, elegant solution to what I was trying to do all along, and, into the bargain, make a number of other things a bunch easier, and more secure. As well as being a lot easier to read in the code, and clearer to document.

I haven’t always been sold on the idea of pair programming. But there are some situations in which it works amazingly well. Having a new perspective on something, and attacking a problem from different sides, often leads to innovative solutions that neither programmer would have arrived at independently. And, at least in my case, it is almost always the very best way to break through a brain cramp, particular one that I’ve been fighting for an extended period of time.

If you’ve never attempted pair programming, it will feel weird the first few times you do it. But you owe it to yourself to try it the next time you get stuck on a particular problem. Or just when you’re trying to solve a particularly sticky issue, and your solution doesn’t feel quite right.