Obvious comment of the day – TDD makes Pair Programming easier

A fairly obvious observation hit me today…

If you are trying to pair program without also doing test driven development, when do you change roles? When doing TDD with Pairing, there is a rhythm to when the roles switch – see Micro Pairing. But if you’re not doing TDD, the person typing is frequently lost in solving a fairly large problem, they are balancing a bunch of things in their heads, and they have to finish a big thought before they could possibly swap the keyboard with their pair. So, while the typer is solving these big problems, what does the other person do? Just sit there? It just seems pretty painful…

I’m sure its not impossible, but it sure seems like TDD is a near necessity for Pair Programming.

Thoughts?

— bab

5 thoughts to “Obvious comment of the day – TDD makes Pair Programming easier”

  1. In my (limited) experience, it seems that the person without the keyboard is the "thinker", and the person with the keyboard types in what the "thinker" suggests, as long as he agrees that it is correct.

    There’s no well-defined point at which to change roles, but I’ve not experienced too much of the "just sitting there" problem. That obviously would not provide much benefit to pair programming. You still do get the benefit of having to think things through, because you have to explain it to the other person before they type it in.

  2. Thanks, Craig. What I’ve found is that what you’re talking about still works better if you’re trying to solve smaller problems. Once you start trying to solve some huge problem, as the person at the keyboard, with all that stuff crammed in your head, the pair becomes disruptive (IME).

    Thinking in smaller pieces and finishing things more often than once every few days I think helps make pairing work better.

    TDD makes it work even better.

    Its entirely possible that you’ve seen different things than me, though. I’ve started changing roles every minute or so, rather than the longer cycles in my youth…

    bab

  3. Yes, and I’ve found that the healthier the code, the more frequently you can switch partners (with ease). On a recent project working with legacy code that had been developed "mostly TDD," but without much refactoring or really disciplined testing, we found that the time needed to comprehend the legacy code limited how frequently we could switch pairs. The better the code got, the easier pair switching became.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.