Pair Programming vs. Code Reviews

I don’t really see how pair programming would help that much. Benefits such as “people understand the project better” and “there’s more team communication” are difficult to quantify and seem more like pie in the sky arguments to me. Intuitively one might say that these things are good things, and it is very easy to falsely believe that this adequate justification for doing it; however that is not the question here. To take a reasoned approach to the problem, this question should be thought of in terms of expectation as it relates to productivity efficiency, and ultimately profit and cost.

The real question is, are these benefits MORE profitable in the long run than the traditional method of one programmer per computer? It’s not good enough to say “well I think pair programming is more profitable because…”. Show us the facts that prove your claim. Show us the quantitative evidence that proves pair programming is more profitable in the long run than single programming. It’s not good enough for it to be “good”, it has to be better than the alternative. Until you can show this, I remain skeptical.

As for the other arguments such as “you won’t write a hack because someone is watching”, nobody should be writing hacks anyway regardless of whether or not anyone is watching. Do you really need someone watching your every move in order to produce professional code? Does a manager have to sit around and babysit you so that you don’t write crap software? For those to whom this applies: you are the programmers the rest of us dread. Stop being lazy and do it right the first time.

I agree with others that some of the ideas behind pair programming sound nice, but until someone is able to show some solid evidence that it works good in practice I am not ready to embrace it. I have a hunch that with pair programming in practice at least one person is wasting about 80% of their time, and that the constant communication between partners disrupts concentration of both. I’m not convinced that’s good for productivity or quality.

I think code reviews are much less time consuming and much less intrusive and (as Jeff also argues) they already give huge benefits if performed correctly. Unfortunately, in practice there is rarely time reserved for code review, and what management cares about most is meeting the next deadline, not ensuring the quality of components that are already more or less functional. In such an environment, introducing pair programming while you are not comitted to performing code reviews properly doesn’t seem right.

These considerations aside, I’m fairly sure I would go batshit fucking insane if I had to work that close with someone the entire day, every day!

Having two programmers at the same skill level working in pair would benefit to both code and programmers, but having two progrmamers at different skill levels can pontentialy damage the code, programmers and project in general.

There is tendency for the better programmer to take a lead of the whole project (same as if he was developing by himself), and put ‘slower’ progammer in more passive role (doco dude). Saying that, frustration can rise from either of two, each wodering why the hell they did pair up. This also raises the question of ‘pairing two coders’. Do you just put them togehter, or you ask them first? Do you match their skill level or does that matter at all? etc…

All this wouldn’t be a problem if we were not both humans and programmers (worst combo) each wanting to play significant role in history or/and the code. Other than that, its a great concept.

The point is you’re never gonna redesign something at a code review, assuming it works. By having the review being a continuous step - the eventual code layout and design is much better. Especially if you’re using TDD.

This is only my experience. YMMV.

Pair programming definitely wouldn’t work for me. I’d end up choking whoever I was paired with. I usually put my headphones on when I code and block the world out. One of the reasons for this is my office is full of chatter and the other is that I normally code better and faster while I’m listening to loud music. I think it clears my mind or gives me a little dose of inspiration.

I’m with the other introverts here. I work best alone. I like nothing better than sitting down with a guru or mentor for an hour or so to learn something new, but all day? And if pair programming is anything like peer reviews I hate the idea. Peer reviews, in my experience, either turn into witch hunts, tickle parties or a forum for the office egomaniac.

When my boss first proposed XP in 2001, I was horrified. One reason was that I just knew that pair programming was a bad idea. I was certain of it. The first few times, I had stage fright. It was hard. Things did not go well. My first pair, to this day, does not let me forget the body-slamming. It took me about 6 months to warm up to pairing, partly because it was hard to get over bad habits. If this sounds like a traumatic experience, that’s because it was. Now I realize that pair programming demands more skill than I had initially reckoned, and depends a lot on who I’m pairing with, and what we’re working on. Pair programming didn’t turn out to be what I thought it was going to be, and when I finally went back to solo programming 3 years later, it was an eye-opener. It’s like the old saying, “the purpose of a journey is to come back to the place where you started, and know it for the first time.”

If you just throw 2 programmers together, there’s no telling whether they’ll pick up the right skills, or spin apart because of personality issues. Also, it’s hardly worthwhile with cubicle furniture where you have to sit in a corner like a bad child – you end up looking over the other programmer’s shoulder. I hate that. I won’t do it. Either ditch the cheap cubicle furniture, or don’t bother trying to pair program. Side by side collaboration is great. Looking over shoulders is not.

If the two programmers are at different levels, it’s automatically a teacher-student relationship. Most programmers are familiar with being a student, but few have any teaching skills. That’s a real problem. Teaching skills are a subset of pair programming skills, and they’re important.

These days, I usually prefer pair programming, but I look at it in a fairly agnostic way. It’s like when a friend called me a “Mac zealot” because I bought a Mac, and I replied, “No, that’s not the issue. The issue is that I know 3 operating systems, and you only know 2.” Same thing: I can pair program, and I can solo program. Can you? There are many programmers that can only solo program, and aren’t even aware that they’re missing something, and will even denigrate me for knowing something that they don’t. (Of course, they spin it a different way.)

I’ve been a professional programmer for over 15 years now, and my experiences with code reviews have been mixed, but I have yet to see a code review produce quality anywhere near as good as pair programming. It’s just not in the same league. But maybe we just never did it right. I hope so. YMMV, as many have wisely observed already. Recently I met a programmer with 24 years of experience, who had never worked on a team, and that shocked me because my experience has been nearly the opposite. Most of my career has been on teams.

I’m currently on my 4th pair-programming team, and once again, I’ve learned something new. I previously thought that pairing made even-numbered teams preferable. But with 7 people, I find that having an odd man out keeps the pair swapping fluid. With an even number of pairs, there is always a problem with pairs locking up, not enough people wanting to rotate. Live and learn. “A man with a watch always knows what time it is. But a man with two watches is never quite sure.” Probably after my next pairing team, I’ll have an even more nuanced view of things.

As for productivity: I think that pairing is somewhat less productive in the short term, but more productive in the long term (on the scale of ~10 months, roughly, YMMV, standard disclaimers apply). This is because of the knowledge sharing when pairing; solo programming teams simply bog down sooner.

One of the interesting things McConnell says is this:
“The variety of errors people found was so great however that any combination of two methods (including having two independent groups using the same method) increased the total number of defects found by almost a factor of 2.”
(This is on page 565 of the first edition of Code Complete.)

This is an amazing statement. Translated into specifics: if you have two independent code reviews, the set of bugs found is almost disjoint! (Please note that having two independent code reviews with small teams in each is completely different from having one review with a lot of people in it.)

This leads me to a refutation of Brooks Law, which states “Adding more people to a late project makes it later.” A more useful law would be: “Adding more people to a late project can make it deliver earlier, if you add people only to the quality control portion of your development process.”

Thoughts?

I think pair programming might work if you have the right people. If you have two people with similar skill levels there probably are benefits. If you stick a skilled developer with a novice then obviously there are going to be problems in that the skilled coder will see it more as a teaching session and the novice will be pressured to keep up. I think code reviews are more practical but there is no substitute for hiring skilled people. I can’t count how many projects I’ve been on with people that had no business being there. If you have people churning out crappy code a code review could turn into a code rewrite.

I was lucky at a previous job, where coincidently, our development team of 5 people consisted of 4 of whom went to the same college together (myself included). We generally worked in pairs on most projects, and was lucky to be teamed up with another programmer on the same level as me. We both learned from each other, bounced ideas off each other and had a deep understanding of the code we were writing. It worked for us because we got along…

However, later on…this approach seemed to turn into more of a starter/closer role. Someone would start a project, and I would end up finishing it. You all can imagine how frustrating that must be. :stuck_out_tongue:

Pair Programming to the extreme can rule out it’s benefits, I have been in environment where I got small doses of it and really liked it. At the same time I realized that I can’t be productive with my ‘Pair’ for just about every type of work, say debugging.

I’ve never had the experience of 100% pair programming. Did something a little similar while working on projects in school, but it wasn’t the same.

Code reviews? My one experience with that was a guy who basically wanted to dictate 100% of the formatting and nit-picking of little implementation details of the code.

Okay, sure, if I was the one in charge, I’d love to dictate that kind of stuff. Whatever my little preferences happened to be, I’d force others to comply, thereby possibly making their lives miserable or viewing me as a major annoyance.

But when you’re just one senior guy (and not like say, the CEO/founder of the company), it’s highly annoying to have to change, say:

forms.first.name[0] to

$(‘foo-form’).name

Or whatever his arbitrary preference would have been.

I can’t help wondering if pair programming is nothing more than code review on steroids.

A bit more, yes. It’s requirements review, design review, test case review, test results review … on steroids. And since it can replace all those reviews, the cost is far less than double.

Further, the two partners can play different roles, with one buried in the code and the other considering higher level designs and implications.

So it’s not two people doing one job, it’s two people doing all the jobs. :slight_smile:

Pair programming needs the right people.

One team I worked on had a rule that all coding had to be done in pairs, but the team was so full of ridiculously strong personalities that I had to battle verbally any time I wanted to get my hands on a keyboard. In this shop, being the Navigator meant hours of passive watching without any feedback as to what the person driving was thinking.

At another company, one developer kept sneaking off to program alone while everyone else was pairing on scheduled tasks. Eventually he developed some really cool stuff made the team’s life easier and which he then of course got all the credit for. I found it humorous that management laid down a policy of pair-programming and then heaped rewards on the dev who paired the least.

These are (hopefully) rare and abnormal cases of course. But even in more normal experiences I have had with pair-programming, it has not been ideal. For example, I think it is the responsibility of the person coding to keep their pair-partner in sync with what they are doing at each moment. I have always done this assiduously when pairing, but I find it interrupts my train of thought to explain what I’m doing with each new piece of code.

Now I work in a job where we use most of the XP practices, but not pair programming. I find this ideal. I can’t tell you what a relief it is to be able to sit and stare at a piece of code and really analyze it and think design decisions through without always having to keep mentally in sync with another person. I’m in heaven.

WOW!

We instituted code review before check in years ago and as long as it is done “appropriately” it is fantastic. Critical architectual issues get close attention, and boiler plate or trivial stuff is given less emphasis.

Peer Programming is great especially when dealing with knowledge transfer on a project. It definitely helps with cross training and generally does not slow things down very much, while allowing better coverage.

Honestly I think that a mixture of Peer Review and Peer Programming works the best depending on the work being done and the quality of your team.

Does this work for every development group?

This requires a very compatible team of high quality developers to be very productive, but obviously that helps in any environment.

We turn away lots of talented developers that won’t play well with our team. This means that we don’t hire developers without good communication skills, introverts who want to hide by themselves, or have “issues” with ownership are primadonnas, etc…

If you have a lot of people who have ego issues and hate sharing their programming experience, there will be problems. Depending on your organization there are two ways to handle this. 1. You are a small organization or can’t afford to lose these people and you cater to their whims to keep them happy. 2. You give them a chance to adapt with some help, and replace them if they don’t work out.

To people who bemoan the “invasion” to their privacy and who want to sit alone in a quiet room without dealing with others all day, I think you are being very short sighted.

It is always hard to leave your “comfort zone”, but don’t write yourselves off. We are in a profession that has an information half life of about 18 months to 2 years. That means we are constantly dealing with change. Learning a new tool is great with short term tangible benefits, but actually changing yourself is forever. Put some effort into overcomming your personally social “issues” and your entire life will improve. I’m not saying it is easy. With a prevalent number of Asperger(ish) people in computer science, social graces are not natural for many developers, but most can learn and adapt if they are willing to try.

Pair programming levels the playing field. An idiot paired up with a super programmer, you get an average programmer.

My worst code ever written was done in pair programming. We both comprised our styles to produce a mismatch crap.

Ownership of code is good as far as the good old Perl virtue goes:

The only thing you need to do is hire good programmers.

There are places for introverts and people who don’t like to work closely with others.

There will always be plenty of small companies with a very small number of “God @ All” developers with management that has no clue what is going on, but manage to trust the technosapiens making things work. These environments will continue to allow introverts who don’t do as well socially to exist the way they want to.

There will also be many waterfall process shops with managers who assign tasks out to the worker bees in their cubes. For many that will also allow them the “privacy” they want. There are some types of projects that this actually makes sense for. Some are classified and such that upper management doesn’t want many discussions of work happening.

There is also contract work if you want to work at home and have enough demand for your work. Of course this means having some business skills, but it does allow you to work how you want to work.

But at companies that are imbracing things like Agile process, developers NEED to communicate better and interact well socially. That does mean that developers in these environments need to have skills outside of technical abilities. These companies will hire those that can be productive in this environment, and let go of those that can’t.

The bottom line is that if you can communicate well and interact well socially you will have far more opportunities for employment and be more valuable.

Orror, yup!
To me it’s like to sit in two on the bog.
Really, when I am in programming mode I have to be alone in the deep of my mental cyber-world. How can I tolerate a nuisance like that? Not speaking of his stink, and worse!
Orror, orror. :frowning:

There should be a place for all personality types to work. It’s kind of crappy to take a profession populated heavily by introverts and force them out for the benefit of people who would do well socially in any job.

Arlo Belshee has done some experiments with “promiscuous pairing” and other methods to increase the efficiency of pair programming, see:

http://stabell.org/2007/07/13/arlo-agile-experiment/

Personally, we’ve used code reviews for the last couple of years, and have had fantastic results in terms of improved quality and cross-learning. We’ve experimented with pair programming on-and-off in many different ways, but haven’t achieved the same efficiency that Arlo’s team did.