Archive for October, 2011

Pair Programming

October 30, 2011

I’ve always maintained that I don’t like pair programming. The reasons for this being self consciousness, resentment because of partners who hog the keyboard, disagreements and tension etc. Having moved to a company, and being in a team, where pairing is strongly encouraged, if not mandatory in some cases, what follows is how to cope with this uncomfortable (for me!) situation.

Regarding the feeling of resentment at someone hogging the keyboard – well if you feel that way just ask to have a go! This is often not easy if you feel that your partner has more experience of the system, more confidence in knowing what to do, or a greater understanding than you. In this situation you could suggest “ping pong” pairing where you take turns to write a failing test and the other makes it pass.

Some recent advice from a wise colleague who told me the following: first of all that he didn’t care if he never touched the keyboard or mouse as long as he had an input into the design. To point out a missing semi-colon or something else the compiler will pick up is trivial – what is important is to listen, to contribute your own ideas and to come to a shared understanding of the design. So, according to my wise colleague, being the “navigator” is by no means subservient to being the “driver” but is a position of great responsibility. If you don’t understand what your partner is doing, and you don’t have any input into the design, then you are wasting your time and you are wasting the company’s time. “You have got to be strong”, he told me, if the other person is going ahead without you then you must always ask questions, make sure that you come to that shared understanding otherwise there is no point. And being shy is no excuse!

I found all that a bit of an alleluia moment (and sadly I feel I should have realised this ages ago).

It is, of course, easier to pair with someone who has a similar style to yourself. For example, if you like to take time to understand things then to pair with someone quicker and sharper than you can be stressful. On the other hand to pair with some hot shot young coder who is very sharp, has a good memory, and uses different design patterns from the same tired old way you’ve been doing things for years may be a good thing. By taking you out of your comfort zone it could force you to raise your game a bit. That’s another way of looking at it. When faced with this situation you could try making some suggestions to improve code quality and if your partner is genuinely delighted with an idea that improves the code then this is a very good sign. In spite of their scary self possession it shows a commendable lack of ego, a willingness to learn, and a desire just to write good code and get things working in a nice way.

If you do make suggestions and your partner gets defensive and wants to do things their way then why not look at the way you are suggesting things – does it display a lack of tactfulness or skill on your part. Perhaps you haven’t thought the suggestion through enough to be able to explain it properly. Or maybe your partner has a point. Try not to get defensive especially pairing with someone you’re not used to. Remember you’ve got to take time to get to know people.

Regarding shyness and self-consciousness ask yourself could this be a form of “ego” on your part. Most people pairing with you aren’t going to test you or put you under the microscope, they’re more concerned with getting the job done. “People have better things to do than look at you you know” (as my Mum used to tell my younger self when I complained about feeling shy or self conscious).

So far these are the ways I’ve coped with pairing and I’ve got to the stage where I quite enjoy some pairing sessions. Also when I think “I don’t like pairing” I try and ask myself why, and is it me that’s the problem? Often it is.