Pair Programming Essentials
To get yourself on the track to better solutions, focus, and team spirit, set aside some of your time for working with someone else.
Join the DZone community and get the full member experience.Join For Free
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 criticizing Pair Programming have never done it or, if they did, don't have too much experience with it. Where does the critique come 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.
Benefits of Pair Programming
Why should you do Pair Programming? Check out a couple of advantages below.
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 you'd feel when working alone, having someone to discuss your ideas and tackle problems with leads to a huge quality boost.
When working in pairs, you are less likely to mess around checking Twitter, reading stuff online, or doing whatever else you do to waste time. I don't mean that any of these things are evil or that you should never do them 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.
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 its 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 painful to let it go.
Built-in Code Review
(You are doing code reviews, aren't you?!)
Having two pairs of eyes to 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.
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 are 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, blah, blah, blah. It's not.
It's way too easy to get griped and end up exhausted after a few hours with suboptimal effects. As with working alone, you need to take breaks. Using the Pomodoro technique is one of the ways to ensure regular and timely breaks.
The fact that you're using your or someone's computer doesn't mean that only you or that person is allowed to touch the keyboard. On the contrary! For best results, you should switch regularly.
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.
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 the 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!)
Published at DZone with permission of Grzegorz Ziemoński, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.