Pair programming is an agile software development technique in which two programmers work together. The goal of agile software development is to deliver software on an ongoing basis so the results can be evaluated more easily.

But how does having two programmers working together improve software development? Read on to learn more about pair programming, how it works, and its advantages and drawbacks.

Some of the very first programmers were the women who worked on the ENIAC (Electronic Numerical Integrator and Computer). These women worked in pairs, allowing them to discuss ideas and improve each other’s work.

Pair programming as a concept didn’t develop until the late 1990s, when agile software development practices were spread to a wider audience.

How does pair programming work?

In pair programming, one person is the “driver,” and the other is the “navigator.” The driver is the person at the keyboard who’s actively writing code. The navigator observes, checks code for accuracy, and keeps an eye on the bigger picture.

Pair programmers switch roles regularly, so both pairs stay engaged. They also work collaboratively, determining which tasks need to be done.

Why use pair programming?

Pair programming is a great educational tool for beginners. Observing other programmers and writing code in front of them are great ways to improve your problem-solving skills.

It’s also a good introduction for programmers who are onboarding with a new company. Learning about ongoing projects by working on them with an experienced and knowledgeable team member can help you stay up-to-date with programming practices. It also keeps individuals from becoming isolated from the rest of the team or project.

Christine Y., one of our Content Contributors, sheds more light on pair programming and how it’s beneficial:

“I personally love pair-programming because I prefer being on the exact same page as someone I’m working with. It creates less room for confusion/error, and I just think solutions are better as 2 minds > 1 mind.”

Pair programming requires communication to work. It improves the code that’s produced, and it’s less likely to contain errors since it’s reviewed by both pairs as it’s written.

Organizations that want to improve the quality of their code, integrate new members into their team more easily, and have development be more collaborative, benefit from using pair programming.

Advantages of pair programming

Here are some of the reasons why organizations use pair programming:

Knowledge sharing

While everyone on a project strives to be knowledgeable, there may be one or two programmers who hold the most knowledge of a project’s codebase. These people are sometimes called “towers of knowledge,” and teams may rely on them heavily. This becomes an issue if progress comes to a halt when those people are unable to work due to sickness or other causes.

Pair programming can ensure that one or two people aren’t holding all the knowledge critical to a project. Pairing them with a variety of programmers helps spread knowledge and keeps them from burning out.

Thinking

Writing code is only a small piece of what programmers do. Most of their time is spent solving problems, so having another programmer to bounce ideas off of and brainstorm with is invaluable.

You can come up with more creative solutions than you would on your own, and you might find solutions faster. Just having someone to talk through a problem with can be key to coming up with a solution.

Focus

It’s easy for your mind to wander when you’re working on your own. Having another person with you and changing roles often can help keep you fresh and focused.

Accuracy

Having someone quality checking the code as it’s being written will improve accuracy. Issues and bugs can be caught immediately rather than down the road when it’s harder to debug. This system makes it easier to improve code as well.

Challenges of pair programming

While there are many advantages to pair programming, it has its flaws, such as:

More complexity

Tasks often done by only one person tend to be simpler than those assigned to two people. For these complicated tasks assigned to a pair, an approach should be created and agreed upon.

Forming the best approach to a problem adds an extra layer of complexity and requires an extensive amount of time and thought. Ideally, programmers will have enough time to work on solo and pair-programming tasks.

Fatigue

When you’re working on your own, you can take breaks and work at your own pace. That’s more difficult when you’re working in a pair, so it’s important to discuss break schedules with your pair programming partner.

Managing skill levels

If there’s a significant gap in skill level between the two partners, one might end up relying too heavily on the other. This could lead to issues with workflow and between programmers.

It’s important for both partners to be open-minded and give the other person a chance to write code, make mistakes, and correct themselves. For example, if the driver makes an error, give them several seconds to correct it before pointing it out.

No alone time

Some tasks need to be done on your own, like email or returning phone calls. Expecting a pair to work together all the time is unrealistic and could lead to burnout. Instead, make it a consistent part of a schedule that includes time to work alone.

Getting started with pair programming

Many organizations use pair programming for improved efficiency. Even if you’re still learning to code, pair programming is a good way to improve your skills. For example, if you’re new to Python, you might want to practice with another student learning Python (or someone more experienced).

If you’re taking one of our classes, consider connecting with other students in our forums or on Discord. You can virtually pair program, and while it has a few more hurdles than in-person pair programming, it can still be beneficial.


Code Foundations Courses & Tutorials | Codecademy
Interested in learning how to code, but unsure where to start? Our Code Foundations domain provides an overview of the main applications of programming and teaches important concepts that you’ll find in every programming language. This content will prepare you to chart a course to a more technical c…

Related articles

7 articles