Engineering Collaboration Practices

Pair Programming

Pair programming puts two developers on one task at one screen. One person, the driver, has the keyboard and writes the code. The other, the navigator, reads continuously, thinks ahead about design and edge cases, and catches problems while they are still cheap. The roles swap often — every few minutes to every half hour — so both people stay engaged and both understand everything that was written.

The obvious objection is cost: two salaries producing one stream of code. The honest answer is that pairing is not free and is not for everything. It pays for itself where defects are expensive, where design decisions are hard to reverse, or where knowledge is dangerously concentrated in one head. It is a poor fit for mechanical work either person could do half-asleep.

Roles Done Well

A good driver narrates: says what they are about to do before doing it, so the navigator reviews intent, not just keystrokes. A good navigator stays at a higher altitude than the current line — tracking the failing test, the edge case the code does not handle yet, the name that will confuse the next reader — and writes small notes instead of interrupting mid-thought. A navigator who only watches silently, or who dictates every keystroke, has left the role.

Rotation is what keeps pairing from decaying into one person working while another watches. Swap on a timer, on each passing test, or at natural boundaries. In ping-pong pairing the rotation is built in: one person writes a failing test, the other writes the code that passes it and then writes the next failing test.

PHP example
<?php

declare(strict_types=1);

function pingPongStep(int $step): string
{
    $phase = $step % 2 === 0 ? 'writes a failing test' : 'makes it pass, writes the next failing test';
    $person = $step % 2 === 0 ? 'A' : 'B';

    return 'Developer ' . $person . ' ' . $phase;
}

foreach ([0, 1, 2, 3] as $step) {
    echo pingPongStep($step) . PHP_EOL;
}

// Prints:
// Developer A writes a failing test
// Developer B makes it pass, writes the next failing test
// Developer A writes a failing test
// Developer B makes it pass, writes the next failing test

When Pairing Pays

Pair on the work where a second brain changes the outcome: gnarly bugs, security-sensitive code, unfamiliar parts of the codebase, and design decisions that will be expensive to revisit. Pair when onboarding — a new developer paired with someone who knows the system learns the codebase, the conventions, and the reasons behind them faster than any document can teach. Do not force pairing on trivial changes, and do not let a pairing schedule override sustainable pace: pairing well is intense, and a full day of it without breaks degrades both people.

Remote pairing works with any screen-sharing setup, and IDE-level tools give both people a live cursor. The mechanics matter less than the discipline: one task, spoken intent, frequent rotation.

Failure Modes

The common failures are human, not technical. A dominant driver who never yields the keyboard turns the session into a demonstration. A distracted navigator turns it into solo work with an audience. Skipping breaks turns it into exhaustion. Pairing a strong ego with a quiet junior without ground rules teaches the junior to stay quiet. Name the roles, rotate on a rule rather than on mood, and end sessions with a two-minute note of what was decided — that note is what the rest of the team reviews and what future maintainers find.

Pairing complements review rather than replacing it wholesale: a pair-written change was continuously reviewed while being written, which many teams accept in place of a separate review pass for that change, but the Code Review As A Skill lesson still applies to everything written solo.

What To Check

Before moving on, make sure you can:

  • describe the driver and navigator roles and what each contributes
  • explain why and how pairs rotate, including ping-pong pairing
  • name the kinds of work where pairing pays and where it does not
  • list the common failure modes: keyboard hogging, silent navigation, no breaks, no ground rules
  • explain how pairing relates to code review

What You Should Be Able To Do

After this lesson, you should be able to run a productive pairing session: pick a task worth pairing on, keep both roles active, rotate on a rule, and leave behind a short record of the decisions the pair made.

Practice

Practice: Design A Pairing Introduction
Show solution

Use ping-pong on test-driven work: one writes the failing test, the other makes it pass and writes the next. On investigation work, swap driver on a 25-minute timer with a 5-minute break each hour. Cap pairing at half a day per person; it is intense, and exhausted pairs produce worse code than rested soloists.

Rotate partners between sessions so knowledge spreads across all four people instead of forming two fixed couples.

Each session ends with a three-line note on the card or pull request: what was decided, what was deliberately deferred, and anything the pair disagreed about. That note is the review trail, since pair-written changes merge without a separate review pass.

After two weeks, retrospect: which sessions felt worth two salaries, and which did not. Keep pairing the former.

Practice: Diagnose A Failing Pair

A senior and a junior have paired daily for three weeks. Output is good, and the senior reports it is going well. The junior privately says they have barely typed, and could not reimplement any of what was built.

Task

Diagnose what went wrong and prescribe specific mechanical fixes, not attitude advice.

Show solution

The fixes are structural, because asking the senior to "share more" changes nothing by Friday:

  • Rotation on a visible timer, no exceptions. When the timer sounds, the keyboard moves.
  • Better, ping-pong: the junior writes each failing test, the senior makes it pass, then roles reverse. The structure forces both to type and both to think.
  • Strong-style rule for a week: the person with the idea must navigate while the other types it. The senior's ideas now have to pass through the junior's hands, spoken aloud, which is exactly the knowledge transfer that was missing.
  • The junior writes the end-of-session decision note. Writing it reveals immediately what they did not understand, while the senior is still there to explain.

The measure of success is not the next sprint's output; it is whether the junior can extend the module alone in a month.

Practice: Define Pairing Health Checks

Define five checks a team lead could run monthly to tell whether pairing is healthy or decaying, each based on something observable rather than on asking "how is pairing going?"

Show solution
  • Session notes exist and name real decisions. Notes that trail off after week two mean sessions have become unstructured.
  • Both names appear as commit co-authors, and driving time is roughly balanced across the month — version control shows who typed.
  • Pairing hours cluster on risky work (incidents, security-sensitive modules, unfamiliar code), not on work paired out of habit.
  • Partners rotate. The same two names every session means knowledge is pooling in a couple, not spreading through the team.
  • Nobody pairs more than about half their day, and calendar breaks exist inside long sessions. Sustainable pace applies doubly to pairing.

One deliberate non-check: per-developer output. Pairing trades apparent individual throughput for defect reduction and shared context; measuring paired developers on solo metrics quietly kills the practice.