Tracy Phillips
CodeSubmit Team
What is Pair Programming? [2023 Guide]
What is pair programming? And how can it help your team level up their code quality and team efficiency?
Pair programming is a collaborative technique that helps developers improve quality and reduce errors while coding. Today, you’ll learn what pair programming is, some of its benefits, and what to keep in mind if you decide to give it a try with your dev team. Keep reading to learn more.
What is pair programming?
Pair programming was designed as an agile software development technique, where two developers work collaboratively and synchronously on the same task. It’s used to improve software quality for teams of all sizes with the goal to reduce the frequency of errors and produce higher-quality code.
Studies have shown that pair programming can result in 15% fewer defects in code, depending on the thoroughness of the coders. Studies have also attributed improvements in design quality, team communication, and the coder's enjoyment of the process to pair programming practices.
Now that we know what pair programming is, let’s explore some of the most common techniques and best practices.
Different pair programming methods
How does pair programming work?
Each of the two participating developers have well-defined roles when pair programming. The programmer at the keyboard is called a “driver,” while the second programmer is referred to as the “navigator.” This duo can structure their work to fit different styles.
There are at least three popular styles or methodologies of pair programming. We’ll cover ping-pong style, unstructured style, and the very popular driver/navigator style:
- Ping-pong style: This style of pair programming is inspired by test-driven development (TDD) and involves one developer (the navigator) who writes test parameters based on what the code is supposed to do, functionally and another developer (the driver) who writes code to pass that test. Once the first test passes, they move onto the next test. They may switch roles periodically, or they may not. The pair works collaboratively back and forth until all of the test parameters have been defined, and code has been written to pass each of the tests. Refactoring typically only happens insofar that a later test case requires it. Ping-pong style is also great for groups of more than two developers, as developers rotate turns writing tests and writing code to solve the tests.
- Unstructured style: With an unstructured style of pair programming, two developers collaboratively write code together in a more relaxed manner. It typically involves two programmers who have matching skill levels, though there is some benefit in having complementary strengths or past experience. These devs will work out for themselves the best method of collaboration and may try out different techniques and paces of work before settling on the methods that work best for them. Unstructured pair programming can be great for tackling less-complicated work in a short period of time (two heads are better than one!) It can also be a useful tool for coming up with elegant solutions to a more complex problem, or providing an opportunity for a less-experienced colleague to collaborate on a task they’ve never tackled before.
- Driver/navigator style: This style of pair programming is one of the more common approaches. One programmer, the driver, owns the keyboard, and will be responsible for actually writing code. Meanwhile, the navigator will define the objectives, guide the driver as they work through the problem, and suggest solutions, approaches or possible test case parameters. The driver and navigator should switch roles regularly, giving both programmers the chance to drive and navigate, lead and execute. This style of pair programming can also be an excellent fit for a novice and expert pair.
Pair programming methods rely heavily on the pairing of the devs, and one method may be preferable over others based on the coders’ experience and skill. Given that not all developers hold the same experience or skill level, pair programming can be a great opportunity to level up beginners who want to improve their skill set.
These pairings include:
- Expert - Expert: When both programmers are highly skilled, they can usually work with an unstructured or more relaxed pair programming method. The possibilities are endless.
- Expert - Novice: This pairing allows the newer programmer to get training and feedback. Experts provide their knowledge and experience to the project, and the novice benefits from their insight and constructive criticism.
- Novice - Novice: This pairing may come with some challenges, especially when two novices attempt to implement the driver/navigator style. At least one novice needs to be more experienced to take action and lead.
Pair programming best practices
Pair programming requires active collaboration to work. Here are some best practices to help you get started:
- Ask for clarification. Clarifying important questions is vital when two coders work together. This is especially important in a novice-expert or novice-novice pair. The novice should ask any questions they have and take advantage of the opportunity to improve and learn.
- Switch roles. It’s important that both programmers working on a project are equally engaged. Switching roles regularly allows for fresh thinking and ensures that both participants are developing their skills.
- Take breaks. Pair programming is a social task as much as it is a problem-solving task. While pair programming is often done remotely, it can still take a lot out of even the most extroverted developers. Avoid becoming drained or overwhelmed by taking regular breaks. Work at a pace that meets both of the programmers needs.
- Work in a familiar environment. Working in a familiar environment allows the pair to maintain momentum and avoid disruption. It may help to work from your home office on equipment you like and are used to working with.
- Communicate constantly. Pair programming is not a quiet activity; there should never be long stints of silence. Communicating regularly can reduce the frequency of errors and improve collaboration. By sharing progress updates often, you learn how to best communicate with each other and improve your workflow.
- Pair the programmers carefully. Although two developers may do great work separately, that doesn’t necessarily mean they will be a good fit together. When selecting a pair or assigning pair programming tasks, choose developers between whom there is as little friction as possible. It's worth considering which pairs will complement each other and how a pairing provides an opportunity to learn from each other. Doing so will contribute to a more enjoyable and effective pair programming initiative at your company.
Remote pair programming
Pair programming can be completed remotely or in person. As hybrid and remote work is getting increasingly popular, remote pair programming is becoming more common. You’ll definitely want to consider which tools lend themselves to good pair programming experiences, so we’ll look more at those software tools later on in this article.
Is pair programming a good practice?
Another question you might be asking:
Should you use pair programming?
Possibly – this depends on your team. Think about the developers you work with and their preferred work style. Do they enjoy working on a team? Do they communicate well? If the answer is yes, then pair programming could be a great fit for your company.
But remember that you need good communication and collaboration, too.
And to help you decide whether or not pair programming is the right fit for your current team, here are some of the most common benefits and downsides:
Pair programming benefits
The goal of many software engineers is to improve overall code quality while building their skills along the way. Pair programming is one way that developers reduce errors and boost efficiency.
Let’s take a closer look at each benefit of pair programming:
Make progress faster
With pair programming, your team can get faster results because they get to share ideas and work through problems together. In addition, one of the pairs might detect an error that may otherwise have gone unnoticed by a single developer.
Increase project resilience
People can get sick or need days off for other reasons. If only one person is responsible for a piece of the codebase, this could lead to a major bottleneck. And if that person leaves your team without proper handover, you risk losing valuable (or even critical) code altogether. Pair programming decreases the “high bus factor” risk of single-point-failure when a team member with all of that knowledge goes on vacation, becomes ill, or leaves outright, by ensuring that at least two people have some familiarity with each part of the codebase.
Boost team morale
Pair programming builds trust and rapport between developers and team members, which means they have people they can rely on and communicate with when they come across problems during their independent work. Nurturing that type of support can be hugely beneficial for team morale. High team morale has tons of benefits itself, including higher work satisfaction and longer retention.
Onboard and train developers faster
With pair programming, junior developers can receive faster training, while experienced developers can level up their expertise. It also helps to increase the speed and efficiency of the onboarding process. New developers can more easily find their place within the team and familiarize themselves with the coding environment, with the help of their coworkers.
Pair programming costs
Despite all of these benefits, pair programming comes with its downsides. The big one is probably the cost. It is estimated that there is at least 15% overhead for systematic pairing compared to individual work, and that makes sense when you’re suddenly paying for two devs to do a job that otherwise would have been assigned to one. On the other hand, many teams report that this initial overhead reduces future costly maintenance to fix errors.
Some other potential challenges of pair programming include:
Engagement issues
If one programmer is off-task or distracted during a pairing session, the benefits of pair programming are greatly reduced. Since the pair must work as a team, there is little benefit for one developer to work with a distracted partner. The distracted programmer is likely not looking to catch errors or check the consistency of the code, leading to more problems down the line.
Communication challenges
While coding, the driver should have a constant stream of verbal communication with their partner. This is also referred to as “programming out loud.” If the driver is not doing this with their navigator, pair programming isn’t as efficient. This can be a challenge for more introverted programmers, who may until that point have felt that they do their best work “in the zone”, independently. Fighting against this mindset, especially if the developer is more senior or highly specialized, can be challenging.
Interpersonal conflicts
Developers need to cooperate to complete a project using pair programming successfully. If there is any friction, the team's progress could be bottlenecked. Not everyone gets along, and while in an ideal world, everyone would maintain their professionalism in the workplace, we all know that on occasion, certain personalities are bound to clash. This is why selecting the pairing is so important. If two developers are not compatible pair programmers, consider pairing them with others on the team to see if a better match can be made.
It’s important to remember that pair programming is an especially social process. It’s very interactive and demands constant collaboration, cooperation and above all: communication. Like anything, pair programming comes with its pros and cons. By being aware of these benefits and disadvantages, you can decide if pair programming is right for your team.
If you decide to use pair programming in your organization, you also need the right tools. Let’s take a look at the top pair programming software tools:
The best pair programming software
What are the top pair programming tools? Here are our picks:
Motepair by Atom
This remote pairing tool claims to be lag-free and includes basic integrations with Share.js, which allows simultaneous editing. It runs pair programming using Github.
Motepair also allows you to deploy your own server on Heroku. The connection currently does not include encryption, so if this is a deal breaker for you, consider another pair programming software.
Tuple
Tuple is a remote pairing app and software that can be used with macOS and Linus. It goes beyond simple screen sharing and enables highly-interactive collaboration. Tuple ensures a low-latency connection, so typing on another screen remotely is not met with issues. It uses a low CPU and offers crisp audio and video.
To start pairing, share a link, and you are good to go. Tuple calls it “one-click” pairing. Tuples’ support is known to be quick, which is also a huge plus in our book.
CodePen
This program is a popular option for designers and developers who want a more social approach. You can select “Collab Mode” to allow multiple people to modify a single pen at the same time.
Programmers can collaborate, chat, type, fork, and edit simultaneously. This software is an excellent option for developers and designers to learn and sharpen their skills.
Pair programming has another function beyond a tool for programmers to collaborate – it’s also a great tool for hiring managers. Here’s what you need to know:
Pair programming in interviews
A pair programming interview is where the interviewer and the candidate work collaboratively to solve a problem. The interviewer acts as the observer or navigator, while the candidate acts as the driver.
Benefits of pair programming interviews
Why should you opt for pair programming for your next interview? Here are a few of the pros of pair programming interviews and how they can benefit your existing hiring practices:
- Make better hiring decisions. You see the candidate in action and under pressure so that you can confirm the candidate's skills, expertise, and communication abilities.
- Speed up the hiring process. Pair programming is a comprehensive approach to testing a candidate’s real-world skills. Hiring managers who know exactly what they’re looking for in a candidate can combine interviews that would have taken multiple stages into one synchronous pair programming interview, allowing for quicker hiring decisions.
- Objective selection process. Using a pair programming interview promotes a more objective hire. The selection is based on demonstrated skill and expertise instead of biased CVs, recommendations, or simple question-answer style interviews.
- Pair programming can be done virtually. Since pair programming can be done remotely, so can the interview – and you get access to a broader talent pool.
- Higher ROI. Hiring correctly the first time around saves you money. Less turnover and higher job satisfaction help companies reduce costs. Research demonstrates a thorough assessment of candidates improves performance goals by 24%. Pair programming minimizes the risk of a bad hire, which can cost up to 30% of the hired employee's salary.
That sounds excellent, right? If you’re ready to try out a pair programming interview, CodeSubmit helps your hiring team set up and manage objectively good pair programming interviews. CodePair by CodeSubmit is a pair programming environment optimized for real-world use cases that supports 24 languages. We offer a ton of features that make it easy to conduct really interesting and company-specific interviews in a matter of minutes.
How to set up a pair programming interview
Start by preparing a baseline assessment – we call them “templates”. This assessment should include the parameters of the coding problem, guidelines for solving it, and the overall goal of the interview. Decide how much you, the interviewer, will assist the candidate during their session.
Make sure the problem you create is based on a real problem. The problem-solving exercise needs to be effective at mirroring your team's tasks. Don't make it too easy, but don't make it impossible. The candidate needs to feel challenged and engaged.
Keep it short; as a guideline, keep the timeframe within 30-60 minutes. If the candidate finishes in less than 30 minutes, the assessment may be too easy.
Finally, prepare a few follow-up questions. This should be a very small portion of the interview, but it's a great opportunity to ask the candidate about their approach to solving the problem to understand their thought process and work style.
Once you’ve prepared the template, you’re ready to go. The only step left is to conduct the pair programming interview!
Over to you!
There you have it! Now you know what pair programming is and how it could benefit your next project.
Try out pair programming on your next project or when assessing your next candidate.
And if you are looking for pair programming interview software, check out our CodePair feature.