Loading…

Pair Programming and How It Can Make You a Better Programmer

Article hero image

Pair programming, where two developers share a single workstation, has grown more common and less controversial over the years, but many still haven’t tried it themselves. In pair programming one participant is the “driver,” who actually writes code, and the other is the “navigator,” who checks the driver’s work as it’s done and keeps an eye on the big picture. The two switch roles every few minutes, and talk to each other throughout the process. This can also be done remotely, of course, using tools like Google Hangouts and screensharing. Studies have shown that, contrary to early objections that the practice would be twice as expensive in terms of “man hours,” coding this way actually adds just 15% more time to the development process, and in exchange returns 15% fewer bugs and defects. Most companies, including Stack Overflow, who use pair programming, find the benefits far outweigh the costs. But what does that mean for you as a developer? Beyond its use in the workplace, many have found pair programming to be a fantastic tool in teaching and instruction. One of our developers at Stack Overflow, Marco Cecconi, calls it his “favorite way of teaching and learning.” This is because it’s a fully immersive learning experience: hearing, seeing, doing, and receiving feedback, all instantaneously.

Two programmers of differing skill levels

When a master and a novice are paired, the novice is in an optimal position to learn and grow very quickly. When the master is the driver, the novice is observing not just what code is being produced, but how it’s being produced. The process gives insight into the thought process, shortcuts, and style of the master developer. It’s akin to watching a gourmet chef cook as opposed to reading a recipe. While the driver narrates as he codes, the novice is able to ask questions and engage in discussion in the moment. When it’s time for the novice to drive, he has the oversight and guidance of the more experienced developer beside him. He can make mistakes without fear, and use them as learning moments. The benefits to the novice are clear, but the master programmer also benefits from the experience. He is exposed to new ideas and thoughts, and made to think critically about his choices so he can explain them clearly. This also cuts down on time put aside specifically for training and teaching that takes away from work; the pair can be doing real work together as they teach and learn.

Two programmers of similar skill levels

When two developers of similar skill levels pair program, there are other benefits. This technique is used effectively to onboard new developers, for example. While their technical skills may be equally matched, one has much more institutional knowledge that can be transferred to the other while accomplishing work together as a pair. When two programmers with similar skill levels and similar levels of institutional knowledge are paired as part of daily operations, the teaching and learning effect can continue, and the final product will likely be of higher quality than if developers had worked independently. When a developer is coding, it’s easy to get lost in the weeds and the details of the problem. If there’s a navigator by your side, he can take a bigger-picture view of the work, bouncing ideas around and pulling your head up for a moment to consider alternative ways to solve a problem. Stack Overflow data team member Nick Larsen points out, “When you’re thinking about the logic, you make little mistakes. In pair programming the navigator cleans them as you go. It’s an informal opportunity to share with other people what you know that they don’t and vice versa.” Wherever you are in your career, there is always somebody who knows things you don’t. In fact, everybody knows things you don’t. And you know things others don’t. Collaboration has always been valued as a way for skilled workers to share their experience, technique, and ideas; programming is no exception.

Pair programming and networking

While certainly not a primary concern in deciding to pair program, the fact that a programming partner can be an effective reference or networking contact should not be ignored. When you’ve pair programmed regularly with somebody, they possess a uniquely intimate knowledge of how you work, what your strengths are, how you approach problems, and how you collaborate as part of a team. You can do the same for them, helping both to strengthen one another’s skills and to further one another’s careers through references and referrals. Do you want to pair program, but need a partner? Make it known that it’s ok to ask by visiting pairprogramwith.me, where you can download a badge to put on your blog or homepage that signals you’re open to pair programming requests (and keep an eye out for this badge on other developers’ sites, too!). Or join a Meetup group like this one, which promises you’ll “meet friendly peers to connect, hack, and collaborate with”:

Why try pair programming if you haven’t before? 1. Learn new tricks and skills 2. Teach others and improve your communication ability 3. Get feedback and insight on things you’re making 4. Make new friends and enjoy hanging out with like minded people.

You can browse all the pair programming Meetups here. Finally, if you have questions and need answers, go where you always go: the Software Engineering Stack Exchange community, which has a tag dedicated to pair programming Q&A.

Getting started and leveling up

As a beginner, you should take advantage of pair programming opportunities whenever possible. The links above can help you get started, and if you have mentors or contacts in the open source world whom you admire, perhaps they would be willing to do some pair programming with you on their current projects. You can’t know unless you ask, and the benefits you’ll reap if somebody says yes have enormous potential to advance your career. Cloud Foundry, for example, is an open source project and community where all code is written in pairs. “We’ve discovered this greatly improves code quality in addition to morale and work/life balance for the developers.” If you’re looking for an internship or a new job, be on the lookout for companies that encourage pair programming for new team members. The practice will likely set you up for better success, faster integration into the team, and more significant growth as a developer.

Do you use pair programming in your work? What have you found to be its costs and benefits? Let us know in the comments.

Login with your stackoverflow.com account to take part in the discussion.