Made a core practice of Extreme Programming by Kent Beck in Extreme Programming Explained (1999), and put to the test by Laurie Williams, whose 1999 experiment found pairs spent about 15 percent more time than individuals and wrote code with about 15 percent fewer defects.
Puts two developers on one task at one screen, one writing the code while the other reviews each line and thinks ahead, trading some extra hours for fewer defects and knowledge shared between them.
Whether pairing pays on one module: the extra hours against the defect-fixing hours it saves
The routing team's trial: a module estimated at 1,000 solo hours, with 300 defects expected later. Set how much longer the pairs take, how many defects pairing prevents, and what a late defect costs; above the curve, pairing pays. Illustrative.
On this modulePairing pays: the defects it prevents cost more than its extra hours.Pairing costs more than it saves at these numbers.
An example
A logistics software company's routing team wanted to pair on its route-optimization engine, where a defect could strand a truck and its driver. Managers objected that two developers on one task would double the cost. The team proposed a one-quarter trial on a new module estimated at 1,000 developer-hours of solo work. Developers paired on everything in the module, swapped the keyboard about every half hour, and changed partners every two days.
The module took 1,200 hours, a fifth more than the estimate. Over the next six months, testing and production turned up about 15 percent fewer defects than the team's history predicted for a module that size: 45 fewer of an expected 300. Each defect found after coding had been costing about 20 hours to diagnose, fix, and release, so the 200 extra hours had saved about 900. Two engineers who had never touched the engine could now support it. Managers approved pairing by default for the risky parts of the system.
The core idea
Pair programming puts two developers at one workstation on one task. One, the driver, writes the code. The other, the navigator, reviews each line as it is typed, watches for missing cases, and thinks about where the design is heading. They swap roles often, and teams that pair widely rotate partners too, so knowledge of the code spreads.
The practice meets the obvious objection, that it doubles the cost, with two claims. First, the cost does not double: two people together spend less time stuck, take fewer wrong turns, and write shorter, simpler code, so a task takes somewhat more combined hours than one person alone, and well short of twice as many. Second, the extra hours buy defects avoided, and a defect found after coding costs many hours to diagnose, fix, and release. Pairing is a continuous review, done while the code is still cheap to change. Whether it pays depends on the work: the more complex the task and the costlier a late defect, the stronger the case.
The thinking behind it
Kent Beck Kent Beck made pair programming one of the core practices of Extreme Programming in Extreme Programming Explained (1999). His method took practices programmers already believed in and pushed them to the extreme, and pairing was code review taken that far: "If code reviews are good, we'll review code all the time." All production code was to be written by two programmers sharing one screen. Pairing also served the method's collective ownership of code, spreading knowledge of each part of the system across the team.
Laurie Williams Laurie Williams put the claims to a test at the University of Utah in 1999. In a controlled experiment with advanced undergraduates, students working in pairs spent, after an adjustment period, only about 15 percent more total time on their programs than students working alone, and their code passed more of the instructor's tests, with about 15 percent fewer defects. In a paper with a colleague she turned the result into an economic case: the extra development hours cost far less than finding and fixing the defects later, in testing or in the field.
Where it sits in the layers
Pair programming is a practice of Layer 10, the daily routine where Extreme Programming from Layer 8 meets the keyboard. It assumes what the Agile Manifesto holds in Layer 6, that individuals and interactions come before processes and tools, and what Total Quality Management holds there, that defects are best caught where they are made. Beside it in Layer 10, it does continuously what Code Review does after the fact, and Mob Programming extends it to the whole team. The common mistake is asking pairing to solve a staffing or skills problem by itself. Pairing a newcomer with an expert spreads knowledge, but used in place of hiring or training it halves the expert's output and leaves both partners frustrated.
How organizations put it to work
Pair programming is owned by the team and its engineering manager, and the choices that matter are where to pair, how to rotate, and what to count. Few teams pair on everything. Most pair by default on risky, unfamiliar, or complex work, such as security code, a core algorithm, or a new engineer's first weeks, and work alone on routine changes. Pairs swap driver and navigator often, every half hour or at each small milestone, and rotate partners every day or two so knowledge spreads. Workspaces change as well: shared screens, two keyboards, and, for remote teams, tools that let either partner type.
Managers have to change how they count output. Two people on one task looks like half the throughput, so the case rests on total cost: time to finish, defects found later, and how many people can maintain each part of the system. Tracking those three over a quarter settles most arguments.
In the first year, expect fatigue, since pairing is intense and few people can do it all day, friction between mismatched partners, and skeptics who count only hours. The return is fewer defects, faster onboarding, and code that no single departure can strand.
Where it goes wrong
The first failure is the passenger. One partner types while the other only watches, and the team pays two people for one's work. Spot it when the same person always drives, or when the navigator cannot explain the code afterward.
The second is the fixed, mismatched pair. An expert dominates, a newcomer stops asking, and resentment builds. Spot it when the same pairs stay together for weeks.
The third is pairing on everything. Simple tasks gain little, and people who think best alone burn out. Spot it when pairing hours rise and defect rates do not fall. The evidence has limits too: a 2009 meta-analysis by Jo Hannay and colleagues found a small gain in quality, faster completion, and more total effort, with signs of publication bias, and the effects depended on the task: on simple tasks pairs finished sooner at some cost in quality, and on complex ones they wrote better code at a much higher cost in effort.
Related and rival frameworks
- Mob Programming. The whole team at one screen. Better when a problem needs every specialty at once, at a higher cost in hours.
- Code Review. A second reader after the code is written. Cheaper per change and better for routine work, though it catches problems later than pairing does.
- Extreme Programming. The methodology that made pairing a core practice, alongside test-first coding, continuous integration, and collective ownership.
Go to the source
- Extreme Programming Explained: Embrace Change, Addison-Wesley Professional, first edition, 5 October 1999, 1999
- Strengthening the case for pair programming, IEEE Software 17(4), 19 to 25, with Robert Kessler, Ward Cunningham, and Ron Jeffries, 2000
- The Costs and Benefits of Pair Programming, Alistair Cockburn and Laurie Williams, XP2000 conference, Cagliari, 2000