Pair Programming – What’s It All About?
Of all the practices associated with agile development the one that developers appear to fear the most is pair programming. This is the practice of literally writing code with a partner. I don’t mean someone to look over your shoulder or who reviews your code after you’ve written it but a partner where all code writing responsibilities are shared. Both partners spend equal time at the keyboard, ideally the desk, chairs and monitor are orientated to give an equal viewing position, the typing role is changed at frequent intervals and both partners constantly engage with each other. An ongoing review process occurs when you have this situation.
Of course there’s no need to be afraid but it is understandable. The practice is quite alien to most developers who are more used to being assigned tasks and working alone, only consulting they’re colleagues when they have a problem.
Advantages of pairing
* Spelling and syntax errors are picked up much earlier when pairing, saving time in the compilation loop – it all adds up.
* Knowledge is shared about the software you are writing. One source of understanding is a bad thing, what if that person falls ill or leaves the company?
* Pairs learn from each other, tools, practices, language knowledge. This is an easy way to share this information and it’s nearly always a two way exchange.
* Constant verification of your evolving design. This works really well when combined with TDD which forces you to think carefully about your code design but only so much as is needed by the requirements you are attempting to fulfill.
I’ve been fortunate recently at work in that I have been able to spend a good proportion of my time pairing. Thanks to this I feel the code we produced was of a higher quality than would otherwise have been possible. I now share at least one of my colleagues feelings of discomfort when writing code without a pair and try to pair whenever practically possible.
I observed an interesting parallel last night while watching Denmark play Indonesia in the Olympic Bronze medal mixed doubles badminton match. The Danish pair ruled the game throughout while technically the players should not have been that dissimilar. The biggest difference and one which was constantly talked about by the commentators was that the Danish pair were in continuous communication with each other. They dominated in part due to their team work and this was due to great communication. Likewise, to be a great pair to program with you have to communicate, what you are thinking has to be said out loud otherwise you are simply two people programming rather than a pair.