Pair Programming: The Most Extreme XP Practice
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.
Join the DZone community and get the full member experience.Join For Free
I was an early adopter of Extreme Programming (XP). I read Kent’s book when it was first released in 1999 and, though I was 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 our own bits of work to do.
With hindsight, I would characterize 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 in 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 organizations 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 are barely social and has the communication skills of an accountant on Mogadon 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 prioritize 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, and that is, “Isn’t it 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 software development isn’t a simple repetitive task. 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 maximize 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.” 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 the output were the only interesting measure, I think that the case for Pair Programming is already made, but there is more.
The 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 codebase.
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 organizations that practice it. Give it a try.
Published at DZone with permission of Dave Farley, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.