Skip to content
tezvyn:

Pair Programming: Two Heads, One Keyboard

Source: Wikipedia: Pair programmingMediumHow cards are made

Pair Programming: Two Heads, One Keyboard

Think of pair programming as a continuous code review. One developer (the Driver) writes code while the other (the Navigator) reviews it in real-time. This is often used for complex tasks or onboarding. The footgun is letting one person dominate the keyboard.

The mental model

Pair programming is a continuous, real-time code review. Instead of one person writing code and another reviewing it hours or days later, two developers tackle the problem simultaneously. One person is the tactical 'Driver' at the keyboard, while the other is the strategic 'Navigator' who reviews, questions, and plans ahead.

How it works

Two programmers work together at a single workstation. They take on distinct roles that they switch frequently, often every 25-30 minutes. The Driver is responsible for writing the code, focusing on the immediate task of translating thoughts into syntax. The Navigator observes the code as it's typed, looking for typos, logical errors, and opportunities for improvement. The Navigator also keeps the broader goal in mind, thinking about the next steps and overall design.

When to use it

This technique shines in specific situations. First, for complex or critical features where the cost of a bug is high; the second set of eyes catches errors early. Second, for onboarding new team members; a senior can navigate while a junior drives, accelerating knowledge transfer. Third, when a team is stuck on a difficult problem; pairing can break through creative blocks.

When not to use it

Pairing is not efficient for all tasks. Avoid it for simple, mechanical work like minor bug fixes or configuration changes, where the overhead of two developers is unnecessary. It can also be counterproductive for highly exploratory or research-oriented tasks where an individual needs unstructured time to experiment. Finally, it can fail if the two programmers have poor chemistry or if one person dominates the session without switching roles.

One canonical example

A senior and a junior developer are tasked with implementing a new authentication flow. The senior starts as the Navigator, explaining the security requirements and overall architecture. The junior drives, writing the code to connect to the identity provider. As they work, the senior spots a potential vulnerability in how a token is handled. They switch roles, and the senior drives to implement the fix while explaining the reasoning. This prevents a security flaw and upskills the junior developer simultaneously.

Interview question

Which situation best exemplifies an appropriate use case for pair programming?

  • a.A new team member is integrating a complex, security-sensitive authentication module.Correct
  • b.An experienced engineer is exploring multiple experimental solutions for a future feature.
  • c.A developer needs to fix a typo in a configuration file.
  • d.Two developers with known personality clashes are assigned to a routine task.
Why?

Pair programming is ideal for complex or critical features, especially when onboarding new team members, as it allows for real-time error detection and knowledge transfer. It is not recommended for simple tasks, highly exploratory work, or when team chemistry is poor.

Just read this? Test yourself on what you have been reading.

Read the original → en.wikipedia.org

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on agile — each one lists the topics its interview covers.

See open roles