I was surprised to read an article in the New York Times about Pair Programming. “For Writing Software, a Buddy System” that advocated 100% Pair Programming.
The New York Times article and Wikipedia give good definitions of pair programming – so I’ll only mention that the main idea behind this methodology is that “two heads are better than one”. While one engineer actually types in the code, the other reviews it, not only for typos, but also for all kinds of “gotcha” in the design, or the implementation.
It is a no brainer that a pair programming setup will lead to better code, written faster than with a simple programmer. The more difficult question, however, is whether this is more productive than 2 developers writing code on their own? In my estimate, No: two programmers will generate better quality code working independently that a programming pair.
I have to admit I have never actually tried pair programming with my teams – mainly because I don’t personally know anybody who has actually done it, and could have overridden my prejudice against it.
This being said, there are benefits that we can leverage from pair programming:
- Code reviews: are definitely worthwhile. The time spent by a peer, or preferably by a technical lead, reviewing the code, is good investment against basic bugs and errors of interpretation in the spec or the design. Code reviews help ensure consistency across the product in various areas such as configuration, initialization, error handling, logging, resource management etc. Consistency leads to a higher quality product.
- More than 1 person knowing any given piece of code: is also great practice. Not only is it good insurance should the original programmer fall under the proverbial bus, but it also helps in debugging, and gives everyone a broader picture of the whole project. It also reinforces the XP principle that the whole team owns the whole code, rather than having a set of individuals who own certain pieces of the code. This shared knowledge is particularly helpful when doing troubleshooting. Finally, this also builds team spirit, and one always learns from the work of others.
What are your thoughts on pair programming? I would love to hear comments from people who have implemented pair programming on a production project.
While I don’t personally have first hand experience I’ve seen it done at my workplace. Sometimes the developers shared a single terminal and sometimes they were physically separated and used NetMeeting. The effort seems to have faded as we always have more work then people available to do it. My own thoughts are that the XP model itself is a little flawed by the thinking that if a little of something is good a lot of it will be great. This philosophy is right there in the name: eXtreme. Whatever happened to the old quote “Moderation in all things?”
Thank you. I agree with your perspective.
While I don’t think pair programming is effective – I am also surprised at how *little* developers ask others to review their code. To me, it makes a lot of sense to have a friendly 1on1 code review every once in a while, and certainly before submitting to QA!