Pair Programming

What is Pair Programming?

Pair programming is a software development practice in which two developers work on the same code at the same time, one writing it and the other reviewing each line, swapping roles frequently.

Updated November 2026 · 3 min read


Pair programming is a practice in which two developers work on the same code at the same time, at one workstation or in a shared remote session. One writes the code while the other reviews each line as it is written, thinks ahead and spots problems, and the two swap roles frequently. Instead of code being written alone and reviewed later, it is reviewed continuously as it is created, and two people understand it from the start.

Pair programming became widely known as one of the core practices of Extreme Programming (XP), which Kent Beck set out in his 1999 book Extreme Programming Explained, though programmers had paired informally long before. The most influential research on it came from Laurie Williams, whose studies at the University of Utah and later North Carolina State University, and her 2002 book with Robert Kessler, Pair Programming Illuminated, shaped how it is practiced and taught.

Roles and Styles

The classic model has two roles:

  • Driver: types the code and focuses on the immediate task, such as getting this function or this test right.
  • Navigator: reviews each line, keeps the bigger picture in mind, considers edge cases and design, and looks things up.

Pairs typically swap every 15 to 30 minutes, or at natural points such as each passing test. Other common styles include:

  • Ping-pong pairing: combined with test-driven development. One person writes a failing test, the other makes it pass and writes the next test, and so on.
  • Strong-style pairing: the rule is that an idea must go from the navigator's head through the driver's hands, so the person with the idea does not type it. It is especially useful for teaching.
  • Mob or ensemble programming: the whole team works on one problem at one keyboard, rotating the driver every few minutes.

Benefits

  • Fewer defects. Many mistakes are caught as they are typed. In a widely cited study, Alistair Cockburn and Laurie Williams found that pairs took about 15% more person-hours than individuals working alone but produced code with about 15% fewer defects, which they argued more than paid for itself in reduced later fixing.
  • Better design. Two people discussing an approach tend to reach simpler solutions and abandon bad ones sooner.
  • Knowledge sharing. At least two people understand every piece of code, which reduces dependence on individuals, the "bus factor."
  • Faster onboarding. New team members learn the codebase, tools and conventions far more quickly by pairing than by reading documentation.
  • Focus. Pairs are less likely to be distracted or to stay stuck on a problem for hours.
  • Built-in review. Code written in a pair has already been reviewed, so many teams skip or lighten the separate code review step.

Costs and Objections

The most common objection is cost: two salaries for one keyboard. The research suggests the overhead is much smaller than double, and is often offset by fewer defects and less rework, but it is not zero. Pairing is also tiring. Most teams that pair heavily do it for four to six hours a day at most, and leave time for solo work. It suits some tasks better than others: complex, risky or unfamiliar work benefits most, while routine changes may not. Personality and power dynamics matter too. A senior developer who dominates the keyboard, or a pair that never swaps roles, gets few of the benefits.

Remote and AI Pairing

Remote pairing is now common, using screen sharing or collaborative editing tools that let both people type in the same codebase. It works well with good audio and the discipline of swapping roles explicitly. AI coding assistants are often marketed as "AI pair programmers." They can play part of the navigator's role, suggesting code and catching some errors, but they do not provide the knowledge sharing, shared ownership or design discussion that are among the main benefits of pairing with a colleague.

An Example

Consider a hypothetical team of six that keeps losing work to the one developer who understands its payments integration. They agree to pair on all payments changes for a quarter, rotating pairs each week. The first two weeks feel slow. By the end of the quarter, five developers can make payments changes safely, the original expert takes a two-week holiday without incident, and payments-related production incidents fall from four in the previous quarter to one.

Common Pitfalls

  • The navigator disengages and watches passively, turning pairing into one person working while another waits.
  • Never swapping roles, so one person always drives.
  • Mandating pairing for everything, including trivial tasks, which breeds resentment.
  • Pairing all day, which leads to fatigue.
  • Measuring individual output, which discourages the shared work pairing depends on.

Pairing is one way to improve developer experience and spread knowledge, and its effects show up in measures of developer productivity and quality.