I was an early adopter of XP. I read Kent’s book when it was first released in 1999 and though skeptical of some of the ideas, others resonated very strongly with me.
I had been using something like Continuous Integration, though we didn’t call it that, in projects from the early-1990s. I was immediately sold when I saw JUnit for the first time. This was a much better approach to unit testing than I had come across before. I was a bit skeptical about “Test First” – I didn’t really get that straight away (my bad!).
The one idea that seemed crazy to me at first was Pair Programming. I was not alone!
I had mostly worked in good, collaborative, teams to that point. We would often spend a lot of time working together on problems, but each of us had their own bits of work to do.
With hindsight I would characterise the practices of the best teams that I was working with then as “Pair Programming – Light”.
Then I joined ThoughtWorks, and some of the teams that I worked with were pretty committed to pair programming. Initially I was open-minded, though a bit skeptical. I was very experienced at “Pairing – Light”, but assumed that the only real value was at the times when I, or my pair, was stuck.
So I worked at pairing and gave it an honest try. To my astonishment in a matter of days I became a believer.
Pair programming worked, and not just on the odd occasion when I was stuck, but all the time. It made the output of me and my pair better than either of us would have accomplished alone. Even when there was no point at which we were stuck!
Over the years I have recommended, and used, pair programming in every software development project that I have worked on since. Most organisations that I have seen try it, wouldn’t willingly go back, but not all.
So what is the problem? Well as usual the problems are mostly cultural.
If you have grown up writing code on your own it is uncomfortable sitting in close proximity to someone else and intellectually exposing yourself. Your first attempt at pair-programming takes a bit of courage.
If you are one of those archetypal developers, who is barely social and has the communication skills of an accountant on Mogadon1 this can, no-doubt, feel quite stressful. Fortunately, my experience of software developers is that, despite the best efforts of pop-culture, there are fewer of these strange caricatures than we might expect.
If you are a not really very good at software development, but talk a good game, pair-programming doesn’t leave you anywhere to hide.
If you are a music lover and prioritise listening to your music collection above creating better software, pairing is not for you.
There is one real concern that people ignorant of pair-programming have. That is that it is wasteful.
It seems self-evident that two people working independently, in-parallel, will do twice as much stuff as two people working together on one thing. That is obvious, right?
Well interestingly, while it may seem obvious, it is also wrong.
This may be right for simple repetitive tasks, but that isn’t what software development is about. Software development is an intensively creative process. It is almost uniquely so. We are limited by very little in our ability to create the little virtual universes that our programs inhabit. So working in ways that maximise our creativity is an inherent part of high-quality software development. Most people that I know are much more creative when bouncing ideas off other people (pairing).
There have been several studies that show that pair-programming is more effective than you may expect.
In the ‘Further Reading’ section at the bottom of this post, I have added a couple of links to some controlled experiments. In both cases, and in several others that I have read, the conclusions are roughly the same. Two programmers working together go nearly twice as fast, but not quite twice as fast, as two programmers working independently.
“Ah Ha!”, I hear you say, “Nearly twice as fast isn’t good enough” and you would be right if it wasn’t for the fact that in nearly half the time it takes one programmer to complete a task, two programmers will complete that task and do so with significantly higher quality and with significantly fewer bugs.
If output was the only interesting measure, I think that the case for pair-programming is already made, but there is more…
Output isn’t the only interesting measure. I have worked on, and led, teams that adopted pair-programming and teams that didn’t. The teams that adopted pairing were remarkably more effective, as teams, than those that didn’t.
I know of no better way to improve the quality of a team. To grow and spread an effective development culture.
I know of no better way, when combined with high-levels of automated testing, to improve the quality of the software that we create.
I know of no better way to introduce a new member of the team and get them up to speed, or coach a junior developer and help them gain in expertise or introduce a developer to a new idea or a new area of the code-base.
Finally, the most fun that I have ever had as a software developer has been when working as part of a pair.
Successes are better when shared. Failures are less painful when you have someone to commiserate with.
Most important of all the shared joy of discovery when you have that moment of insight that makes complexity fall away from the problem before you is hard to beat.
If you have never tried pair programming, try it.
Give it a couple of weeks, before assuming that you know enough to say it doesn’t work for you.
If your manager asks why you are wasting time, make an excuse. Tell them that you are stuck, or just “needed a bit of help with that new configuration”.
In the long run they will thank you, and if not find someone more sympathetic to what software development is really about.
Pair programming works, and adds significant value to the organisations that practice it. Give it a try.
Dave Farley 2016
1 A Medical Drug used as a heavy sedative.
‘The Case for Collaborative Programming’ Nosek 1998