3 min read

Pair Programming

Pair programming is an agile software development technique in which two programmers work together at one workstation. One, the Driver, writes code while the other, the Navigator, reviews each line of code as it is typed in. The two programmers switch roles frequently.

1. The Roles

The Driver

  • Responsibility: Typing the code, focusing on syntax, semantics, and the immediate task at hand.
  • Mindset: Tactical ("How do I implement this function?").

The Navigator

  • Responsibility: Reviewing the code, thinking about the bigger picture, spotting bugs, and considering edge cases.
  • Mindset: Strategic ("Does this fit the architecture? Are we solving the right problem?").

2. Styles of Pairing

Ping Pong Pairing

Often used with Test Driven Development (TDD).

  1. Person A writes a failing test (Red).
  2. Person B writes the code to pass the test (Green).
  3. Person B writes the next failing test.
  4. Person A writes the code to pass it.

Strong Style Pairing

The rule is: "For an idea to go from your head into the computer, it must go through someone else's hands."

  • The Navigator does all the thinking and verbalizes it.
  • The Driver does exactly what the Navigator says.

3. Benefits

  • Higher Code Quality: Two pairs of eyes catch bugs immediately.
  • Knowledge Sharing: Junior developers learn from seniors; seniors learn new tricks from juniors. No "silos" of knowledge.
  • Focus: It is harder to get distracted (check social media) when someone is watching you work.
  • Resilience: If one person leaves or gets sick, the other knows the code intimately.

4. Challenges

  • Exhaustion: Pairing requires high focus and communication, which can be draining.
  • Personality Clashes: Requires empathy and good communication skills.
  • Skill Gaps: If the gap is too wide, the junior might disengage or the senior might get frustrated.

5. Mob Programming

Mob programming (or ensemble programming) is an extension of pair programming where the entire team works on the same thing, at the same time, in the same space, and at the same computer.

  • The Driver: Only one person types at a time.
  • The Navigators: The rest of the team discusses the solution and guides the driver.
  • Rotation: The driver rotates frequently (e.g., every 10-15 minutes).
  • Goal: To maximize flow efficiency (getting items to "Done") rather than resource efficiency (keeping everyone busy).

6. Remote Pairing Tools

With the rise of remote work, pair programming has adapted using specialized tools that allow for low-latency collaboration.

  • VS Code Live Share: Allows developers to share their editor context (not just screen) in real-time. Both can type, run terminals, and debug simultaneously.
  • JetBrains Code With Me: Similar to Live Share but for IntelliJ-based IDEs (IntelliJ IDEA, PyCharm, WebStorm).
  • Tuple: A dedicated remote pair programming app designed for low latency and high-quality screen sharing, specifically for macOS (and Linux/Windows).
  • Screen Sharing (Zoom/Slack): The simplest method, but often suffers from input lag if the remote person needs to drive.

programming/agile-methodology programming/code-review-best-practices programming/test-driven-development