Pair Programming Essentials

It appears to me that Pair Programming is, next to TDD, one of the most controversial of XP practices. It also appears to me that most people criticising Pair Programming have never done it or, if they did, don’t have too much experience with it. Where the critique comes from? Comfort zone. You have to leave your shell behind and expose yourself to making mistakes in front of someone else and to prolonged communication. Basically, you’re forced to get rid of your ego and any kind of code authorship for the sake of benefits you might not see or believe in.

Why Pair Programming?

There has to be some advantage you get by Pair Programming, if you’re ever supposed to agree to something like this.

Two Heads Are Better Than One

It’s obvious that you will solve problems faster and produce better designs when you’re working with someone. However more comfortable wouldn’t you feel when working alone, having someone to discuss your ideas and tackle problems with, leads to a huge quality boost.

Prolonged Attention

When working in pair, you are less likely to mess around checking Twitter, reading stuff online or whatever else you do to waste time. I don’t mean that any of these is evil and you should never do it at work. I mean that when it’s time to get to work and get things done, it’s way easier to focus and not get distracted when there’s someone working with you. Also, when you feel tired or just a bit off track, you can simply switch roles and keep working.

Collective Ownership

Reading the code written by someone else gives you a completely different view than actively participating in writing it. With Pair Programming, every piece of code has two authors with deep insight into it’s creation process. If you rotate your pairing partners and participate in a variety of tasks, you have a much wider perspective on the codebase. Because you have to suppress your ego when pairing, you are less likely to be protective when it comes to deleting or changing your code. It’s much less pain to Let It Go.

Built-in Code Review

(You are doing code reviews, aren’t you?!)

Having 2 pairs of eyes see and review the code, you can either relax your code review process or let it go completely. Depending on your team, it can be a huge time saver.

Team Spirit

Regularly cooperating with your team members builds up a real team. You can’t achieve the same level of understanding and the same feeling of a collective when sitting alone with your headphones on. Effective cooperation is more than daily stand-ups and bi-weekly ceremonies. It’s daily discussions, whiteboard sessions and writing code together.

For sure, there’s more benefits than that. I chose the ones that are most important and appealing to me.

How To Begin?

Now, armed with a fantastic vision of all the benefits associated with Pair Programming, you’re ready to start doing it yourself. Here are a few practical tips:

  • Just do it – too many people give up, before they even try, justifying that they are better working alone, that management won’t agree, that their project is special, bla, bla, bla. It’s not.
  • Take breaks – it’s way too easy to get gripped and end up exhausted after a few hours with suboptimal effects. Same as with working alone, you need to take breaks. Using Pomodoro technique is one of the ways to ensure regular and timely breaks.
  • Switch roles – the fact that you’re using your or someone’s computer doesn’t mean that only you/that person is allowed to touch the keyboard. On the contrary, for best results, you should switch regularly.
  • Change partners – working all the time with the same person would limit the benefits of collective ownership, reviewed code and improved team spirit.
  • Set aside some time alone – despite the various benefits of working together, it’s still important to have some time for yourself, put your headphones on and bash some code alone.

Summary

Pair Programming is about moving the emphasis from individual’s ego to the collective by writing code together. There’s a lot of benefits to this approach, despite the discouraging voices of the naysayers. To get yourself on track to better solutions, focus and team spirit, set aside some of your time for working with someone else. Make sure to keep things diversified – take breaks, switch roles and change partners regularly for the best effect. Enjoy! (Yes, Pair Programming can actually be enjoyable!)

About the Author Grzegorz Ziemoński

King of Tidy Java, nerd that thinks about producing perfect software all the time and proud owner of 2 cats.

follow me on: