Pair programming

Pair programming is working together on one laptop, or one feature together. When pairing, it's important for both developers to feel comfortable and able to contribute.

When to pair

When you're working through workshops in class time, and during your projects. When you start work with your employer, you'll be likely to be pairing for a decent chunk of your time.

Methods

There are a thousand ways to work together. Figure out what works for you, and communicate with your partner about that to find a balance that works for you both.

Here are some suggestions for how you might work together:

Ping pong. Take turns writing code. How much code you write depends on the context. Maybe, one developer writes a line of code and then the other writes a line of code. In another case, one developer starts by creating a single failing test and then each developer takes it in turns to first write code to make the test pass and then to write a new failing test before passing the keyboard back to their partner. On your projects, you might extend this, perhaps by writing for 10 minutes and then swapping who is 'driving'

The back-seat driver. One developer shares their screen and follows the instructions of the other developer. The person 'driving' is the one typing and should follow exactly the instructions of the 'navigator'. If the navigator is lost and would like a suggestion, they can ask the driver where they think to go next or suggest somewhere to look online for a solution.

Tips and Tricks

Getting better at pairing, is not just about being better at writing code. Develop your verbal communication. It’s hard to work with someone if they don’t verbalise their thoughts/reasoning and if there’s no dialogue between the two of you when typing. When pairing, both developers should be active and neither should be a shadow to the other.

It's important to switch roles, don't let one person do all the coding. You get more out of it by getting stuck in. Switch regularly and give the other person time to read through the code base before they take over. Being able to talk though someone else's code is a vital skill to have and will enhance your understanding.

If pair-programming remotely, weigh up your options with care. Screen-sharing guarantees that you’re both looking at the same piece of code together, but puts the power to change that code in the sharer’s hands alone. VSCode also allows Live Share, where both programmers can type at once. This can be more dynamic, allowing faster corrections to code and letting the second programmer view other parts of the codebase easily, which can be helpful when you need to follow the trail of a function across different files. Without clear communication, Live Share can become chaotic, even more so if one or more parties has connection issues.

Last updated