Pair programming can be tough for even the best developers. It can be downright daunting if you haven't done it before, are introverted or unsure of yourself. For those of you who want to improve your pair programming abilities, the following seven secrets are helpful strategies in accomplishing that objective. They are distilled from my 10 years experience pairing as a developer, technical lead, test driven development mentor and Agile coach.
Pair Programming Secret #1. Proficiency
Proficiency with the language and proficiency with the IDE are paramount to working as an effective pair partner. When you program with a pair partner you have nowhere to hide. All of your skills and abilities, along with your fears and shortcomings, will be on display for the team to see. To overcome these challenges, you must first accept that there will always be someone out there who knows more than you do.
Secondly, you should work to improve yourself in the places where you feel weak or unsure. Try spending 30 to 60 minutes per day, for a couple of weeks, on self-improvement in the areas you are worried about. You'll be surprised by the results.
Finally, you must master your IDE. Almost all modern IDEs have a wide range of shortcut keys for the most commonly used actions and commands. Find a reference card for your IDE on the Internet and highlight the ones you think will be most useful to you. Then memorize the shortcuts and start using them every day. Your pair partner will appreciate your mastery of the IDE and you will improve your efficiency.
Pair Programming Secret #2. Communication
In any relationship, communication is key. Pairing is a very intense, albeit short relationship between two people working collaboratively towards a shared goal. Before you dive in to writing code, spend a few minutes discussing the task and identifying an approach to implement a solution. Doing so will ensure that you and your pair partner agree on what to do and how to do it.
When it's your turn at the keyboard, keep your pair partner informed. You need to verbalize your thought process to let your pair partner know where you are heading and why. Try to articulate what you are doing and ask your pair partner questions to help keep him or her involved and engaged. For instance, after passing a test, I will often say, "What do you think?" and offer the keyboard. This is a chance for my pair partner to improve, refactor or write another failing test.
Pair Programming Secret #3. Self Confidence
When you are confident in yourself and your abilities, you feel comfortable offering and receiving constructive criticism. Self awareness of your strengths and weaknesses, coupled with a confidence that you "can do this" allows you to relax and focus on your work rather than on your shortcomings. Additionally, you will be able to open yourself up to constructive criticism and you will have the perspective necessary to determine if the criticism is relevant and actionable.
With self confidence, you will find that you are more willingly to ask questions and try out new ideas. Your self confidence can inspire better communication on the team by setting the example that you are willing to admit that you don't know everything and are willing to ask for and accept help. When you're self confident you don't worry about what others are thinking about you or about your productivity, so you are more willing to take chances and try innovative solutions.
Pair Programming Secret #4. Self Control
The discipline of software development requires a significant amount of mental effort and focus. It's easy to have self-control lapses when we are bored, tired or frustrated. Anything that distracts your attention can be a potential productivity killer.
The high-functioning teams that I have witnessed leverage their "team norms" or "ground rules" to help reduce the number of potential distractions. You can also leverage good Agile principles to stay focused. Use spikes to investigate new ideas and techniques. Add a "time allowance" to your spike story to keep from going down an endless "rabbit hole." These are key because when you're working on an Agile team you're responsible not just for yourself, but for everyone else on the team. That's what we mean by the "whole team approach."
If you're having trouble focusing, you should be able to rely on your pair partner and your team to help get you back on task. Just the same, if you notice that someone else is having a hard time staying focused, you need to be willing to step up and help them get back on track. Remember, you will succeed or fail as a team.
Pair Programming Secret #5. Patience
We have clearly established that writing code with a pair partner is very different from hacking alone all day. Your patience, or lack thereof, doesn't usually affect others when you're working alone. If you've spent your whole career as a solo "keyboard jockey," pair programming will put your patience to the test.
As a pair partner you won't always have control of the keyboard and mouse, and it is considered bad form to rip the mouse out of your partner's hands. So when you get the urge to grab, take a deep breath, exercise your self control, and then use your best manners to ask, "May I?"
Once you get control of the keyboard and mouse, you should be willing to relinquish it without a fight. Liberal keyboard passing helps keep both pair partners engaged and motivated. Some of the best athletes in team sports are the ones willing to sacrifice a small personal victory and make a pass to a teammate in order to achieve a larger team "goal."