Simyl
simylflow
Course Home
Module 2: Technical Practices
Lesson 2 of 5
13 min

Pair Programming

Two developers, one keyboard, better code. Learn when and how to pair effectively.

1Why Two Brains Are Better

Pair programming means two developers working together at one workstation. One types (the driver); one observes, thinks, and navigates (the navigator).

This seems inefficient. You're paying two people to do one person's job. But the math works out differently than you'd expect:

  • Fewer bugs reach production (the navigator catches mistakes in real-time)
  • Knowledge spreads through the team (no knowledge silos)
  • Code quality improves (real-time code review)
  • Junior developers level up faster (learning from seniors)
  • Focus improves (it's harder to check Twitter when someone's watching)

Studies show that pairs produce code with 15% fewer defects while taking only 15% more time. That's not twice the cost for better quality—it's a 15% investment for dramatically better results.

The most expensive line of code is the one that causes a production incident at 3 AM. Pair programming catches those lines before they're written.

2Driver and Navigator Roles

The classic pairing model has two roles:

The Driver holds the keyboard. They:

  • Type the code
  • Focus on the immediate task (syntax, this line, this test)
  • Think tactically about implementation
  • Talk through what they're doing

The Navigator watches and thinks. They:

  • Review code as it's written
  • Think strategically (does this design make sense?)
  • Keep the bigger picture in mind
  • Catch typos, logic errors, and design issues
  • Look things up when needed

Switch roles regularly. Every 15-30 minutes, swap. This keeps both partners engaged and prevents one person from dominating.

The navigator is not passive. If you're navigating and you see something wrong, speak up immediately. Don't wait. The value of pairing comes from continuous feedback.

3Pairing Styles

There are several effective pairing styles:

Ping-Pong Pairing (works great with TDD):

  1. Person A writes a failing test
  2. Person B makes it pass and writes the next failing test
  3. Person A makes it pass and writes the next failing test
  4. Continue alternating

This keeps both people actively coding and maintains TDD discipline.

Strong-Style Pairing: "For an idea to go from your head into the computer, it must go through someone else's hands."

The navigator tells the driver what to type. The driver only types; they don't make decisions. This is great for teaching—the junior types while the senior navigates, forcing knowledge transfer.

Tour Guide Pairing: One person knows the codebase; the other is learning. The expert drives and explains, giving a tour of the code. Then they swap, with the learner attempting tasks under guidance.

Pick the style that fits the situation. Ping-pong for TDD. Strong-style for mentoring. Tour guide for onboarding.

4Remote Pairing

Pairing works remotely too. You need:

  • Screen sharing with low latency (VS Code Live Share, JetBrains Code With Me, or screen share with remote control)
  • Voice communication (constant audio connection)
  • Camera optional but helpful (seeing reactions and body language)

Remote pairing tips:

  • Use a tool that lets both people type (not just screen share)
  • Take more frequent breaks—remote pairing is more tiring
  • Over-communicate verbally (you can't read body language as well)
  • Agree on editor settings and keybindings before starting

Some teams find remote pairing works even better than in-person because there's no "lean in and take the keyboard" temptation. Each person stays in their role.

5When to Pair (and When Not To)

Pair on:

  • Complex problems where two perspectives help
  • Critical code paths (authentication, payments, data integrity)
  • Unfamiliar code (one person knows it, one is learning)
  • When you're stuck (fresh perspective breaks logjams)
  • New team member onboarding

Consider solo work for:

  • Simple, routine tasks (updating config, renaming things)
  • Exploratory spikes (when you need to think alone)
  • When one person has deep expertise the other can't contribute to

XP doesn't mandate 100% pairing, despite common belief. The original XP specified pairing for production code, but modern XP recognizes that effective teams mix solo and paired work based on context.

The key: never let code go to production without review. If you don't pair on it, review it. Pairing is just real-time code review.

Start by pairing on the hardest problems. Once you see the benefits there, expand to more of your work.

6Common Objections

"Our developers don't want to pair." Start slowly. Pair on hard problems only. Let people experience the benefits. Don't force 100% pairing on day one.

"We can't afford two people on one task." You can't afford production bugs either. The economics favor pairing when you account for reduced bugs, shared knowledge, and improved code quality.

"Senior developers will be slowed down." Sometimes. But seniors pairing with juniors accelerates the whole team. The senior's knowledge spreads. The junior levels up. It's an investment in team capacity.

"Introverts hate pairing." Some introverts love pairing because it's structured interaction with a clear purpose. Others need solo time to recharge. Respect individual needs, but don't assume introversion means anti-pairing.

"Pair programming is exhausting." It is more intense than solo work. Take breaks. Don't pair for 8 hours straight. Mix pairing with solo work, code review, or design work.

Key Takeaways
  • Pair programming catches bugs in real-time through continuous review
  • Driver handles tactics (typing); Navigator handles strategy (thinking ahead)
  • Ping-pong pairing works especially well with TDD
  • Remote pairing works with the right tools—low-latency screen sharing is essential
  • Pair on complex, critical, or unfamiliar code; consider solo for routine work
Common Pitfalls to Avoid
  • The navigator going passive (they should be actively thinking)
  • One person dominating (swap roles regularly)
  • Pairing for 8 hours without breaks (it's exhausting)
  • Expecting 100% pairing from day one

Practice Exercises