Pair Programming Explained - How to Pair Program and Code with a friend

Pair programming is best described as two people writing code together on a single device.

Pair programming encourages you to discuss different approaches to solving problems, and to keep one another other motivated. The result should be better code than either of you could have probably written individually.

Typically the pair consists of a “driver” who is at the keyboard, and a “navigator”, who is also actively engaged in the programming process.

Because of the benefits, many engineers pair program on a regular basis. It is also a very good way to learn coding. There are tools that allow two people to share mouse and keyboard inputs, enabling you to pair program with a friend or coworker without needing to be in the same room.

You can experience these benefits by pair programming with other Free Code Camp students on our coding challenges. Eventually, you’ll work with people at nonprofits to build real-life software solutions.


Why should you pair?

When I started working through my first Algorithms, I was really scared of speaking to strangers. What would this person think about me? Would I even be able to write good code with someone watching me?

Now, some weeks later I’ve pair programmed and reviewed code with more than 40 campers and let me tell you: it’s not as scary as it seems. It’s perfectly normal to feel that way. Most of the campers that I’ve talked to agree that they were nervous too.

Here are a few good reasons to try pair programming (I wish I knew this when I started…):

You can…

  • Build your professional network
  • Meet new friends - develop a support group
  • Improve social skills
  • Get motivation and encouragement from fellow campers
  • See other’s coding styles
  • Learn from each other
  • Strengthen your strengths and get help finding and improving your weaknesses
  • Pair with more experienced dev to improve your skills
  • Pair with less experienced dev to test your knowledge
  • Gain a new skill that will be useful for interviews and employment down the road

With the right person, pair programming is one of the best ways to learn at the same time as you make new friends!


Tips on becoming a good pair programmer

  1. Communicate well with your partner. Voice chat will make communication easy, let you focus on learning, and will allow you to use your time effectively.

  2. Before you start coding: decide together with your partner how your workflow should look so that both you and your partner can benefit from the time spent coding. An example of a good workflow:

    • Read through and discuss the problem to make sure you understand it.
    • Solve the problem with pseudo-code by identifying the steps you need to take in order to get from the given inputs to the expected result.
    • Create your actual solution
  3. When explaining things: Ask questions to guide your partner’s thoughts instead of just showing the answer right away. This will let him or her think about the problem and make it easier for them to learn.

  4. Finally, be open to your partner’s ideas, respect each other and have fun! :slight_smile:


Pair Programming and Why it is special

Pair Programming is an Agile Development practice that was born out of the Extreme Programming movement.

Working as a team of [exactly] two, at a single computer, the pair will slide the keyboard and mouse back-and-forth throughout a “pairing session”. This increases the code quality by providing a “greater than the sum of its parts” effect of two developers working on a single problem domain.

The increase in quality of the code, combined with the effect of knowledge and understanding on the project being spread across multiple developers, can produce a large savings in cost on the project as a whole.

In a Test Driven Development (TDD) shop, it is most common for each member of the pair to take turns a) writing a test and b) writing code to pass the test. This “ping pong” yields a cumulative effect on the overall quality of the final product.

To be most effective it is important that pairs are intermixed; not the same couple of developers always working together.

Pair programming is considered to be very “social”. It can be akin to a marriage because you learn to cooperate with a peer in a close, give-and-take relationship. As such it is often very difficult to become comfortable with pair programming. Some developers simply NEVER feel quite at-home. In the end, the willingness to share, be a bit vulnerable and work cooperatively toward a better product will make you a far better developer (and a better person overall).

1 Like