Pair Programming: What, Why, and How

Learn why you should pair program and how to do it effectively. Partner with an experienced mentor for a better paired programming experience.

learn-about-pair-programming

What is pair programming?

Pair programming is the practice of pairing up to work on programming tasks. Usually, most people imagine two developers seated at the same computer, sharing the keyboard. But with the increasing popularity of remote coding platforms, it’s now possible to pair program thousands of miles apart.

Both members must verbalize their thought processes for paired programming to be effective. Successful pair programming relies on successful communication as much as programming skill. The premise is that when working on a complex task, “two heads are better than one.

Find a senior developer to be your pair programming partner

Why is pair programming important?

  • dot

    Produce better solutions

    The most important reason to pair program is that it often produces better solutions than either developer could have produced on their own. Problems are picked up on earlier and potential bugs are identified by two people instead of one. Before the pair settles on an approach to a particular problem, they discuss, evaluate, and talk through any trade-offs involved. Solutions are evaluated up-front rather than after they’ve already been implemented.

  • dot

    Share knowledge and context on the fly

    Pair programming provides a process for sharing knowledge and context that is built into your everyday workflow. For every line of code written while pair programming, two people have context on the code instead of one. This provides built-in redundancy if one person leaves, moves to a different team, is busy with other work, or goes on vacation. Without pair programming, developers must go to extra lengths to share knowledge, usually through extra meetings and code review sessions.

  • dot

    Mutual learning and skill development

    One of the biggest benefits of pair programming is learning from your partner. Pairing with a more senior developer is the best way for junior developers to improve their skills. Senior developers can also learn new things when pairing with a more junior developer, be it a nifty Linux command they didn’t know, how to use a new IDE, or how to be productive in the latest front-end framework. Everyone's an expert in something, and everyone has something to teach.

Find a mentor to be your pair programming partner

find-pair-programming-partner

How does pair programming work?

The requirements for pair programming are minimal: two developers and a shared command line or code editor. With these basic ingredients in place, there are many ways to pair program, from the “Ping Pong Pattern” to much less structured forms. We’ll dive into different techniques for pair programming in the sections below, but they all have two critical things in common: turn-taking and open communication.

What are the main pair programming techniques?

  • dot

    Ping Pong

    This form of pair programming is performed in conjunction with Test-Driven Development. One person writes a test and the other person makes the test pass. This pattern is effective because taking turns is built into the process. Make sure each member alternates between writing tests and passing tests. This can become a Ping Pong anti-pattern if the same person is always writing the tests (often the more junior or less confident developer) and the same person is always making them pass (often the more senior or more confident developer).

  • dot

    Driver-Navigator

    This form of pair programming is a looser form of the Ping Pong Pattern. It works a little bit like two people driving in a rally car race, with one person driving (or typing) and the other navigating. The driver carries out the navigator’s instructions, but has the opportunity to make corrections or ask for clarification. This style is an effective antidote for the anti-pattern where the person typing often controls what is typed, placing the other person in a passive mode where they are merely watching what is happening. The driver and navigator regularly switch roles every 15 minutes or so.

  • dot

    Unstructured Pairing

    This is the kind of pairing that generally happens when no particular approach is being followed. It is free-flowing, with turn-taking between driver and navigator occuring as, and when, it makes sense. This freedom from structure can help naturally well-matched pairs move even faster. However, pairs that have different styles may struggle with the lack of structure involved here.

Learn how pair programming on Codementor works

What makes for a good pair programming partner?

Pair programming is most effective when both people bring something unique to the table, whether that is knowledge, experience, or a diverse perspective. If you have the opportunity to choose your pair programming partner, it’s best to seek someone who can fill a gap in your knowledge or provide you with a different perspective.

How do I pair program effectively?

  • dot

    Keep talking

    Pair programming should never be done in silence. When a pair is silent, it might mean they are so perfectly in-sync that nothing needs to be said — this is rare. More often, it means that they are not sharing their thought processes. Whether you’re sitting with your partner or communicating remotely, good paired programming involves a lot of talking and thinking out loud. A good trick is to always narrate what you are doing and thinking whenever you type.

  • dot

    Spend equal time typing

    When one person types for a prolonged period of time, usually more than half an hour, this can be a symptom of poor pair programming. If the roles of driver and navigator are being properly shared, both members will take turns typing. If one person tends to dominate the keyboard, it may be helpful to set an alarm for 20 minute intervals to encourage role swapping. In pairs with a more senior person, the senior person must take particular care not to seize the keyboard whenever the junior person is struggling or going slowly.

  • dot

    Use a development environment that both people are equally comfortable with

    Don’t be the person who insists your pair programming partner uses your hyper-customized Vim or Emacs with a thousand plugins unless they are as comfortable with Vim or Emacs as you are. By insisting on an environment that is unfamiliar to your partner, you’re doubling the cognitive load they must work through. If you are much more productive in the development environment than your partner, or vice versa, the balance of pair programming will be disrupted, and your partner will be less willing to “drive.” Use an IDE that you are both roughly equally comfortable with and use your highly customized environment as much as you like when you’re working alone.

remote-pair-programming

Start Remote Pair Programming Now

A better paired programming experience with Codementor

Codementor is a online community of software developers with over 350K+ users and 10K+ vetted mentors. Our mentors make it their mission to help people just like you using tools like video calls, screen sharing, and shared code editors.

10,000+ mentors

10,000+ mentors

We have a community of 10K+ mentors who are waiting to help you!
A variety of technologies

A variety of technologies

From help with JavaScript, Swift, React, and more, keep up to speed with good programming practices.
All day, every day

All day, every day

Our mentors are located all over the world across different timezones, so you can get help whenever you need it.
Stringent vetting process

Stringent vetting process

Our mentors go through a strict application process that evaluates their technical and soft skills.
Video call & screen sharing

Video call & screen sharing

Use tools for video calling, screen sharing, and code editing with your mentor.
Billed per minute

Billed per minute

Only pay for the time you actually spend with a mentor.

Mentors Available for Pair Programming

"Two heads are better than one," especially when paired with an experienced mentor who knows when to give you a nudge in the right direction and when to step back. Connect with a senior developer for an effective remote paired programming session now.

C# - Ed Mays

Ed Mays

5.0
562 Sessions / Jobs

I am an experienced, committed software engineer who continually seeks clean, elegant solutions to business

Pair programmingC#Code review+5
JavaScript - Johnny B.

Johnny B.

5.0
1381 Sessions / Jobs

Hi! My name is Ionică Bizău. If you're having problems pronouncing it, you can simply call me Johnny

Pair programmingJavaScriptCSS+10
Python - Jessamyn Smith

Jessamyn Smith

5.0
2992 Sessions / Jobs

I am an experienced full-stack software developer with over a decade in the field, primarily in back-end...

Pair programmingPythonJavaScript+17

Get Started with Remote Pair Programming

Get started with pair programmingGet started with pair programming