Pair programming is a programming technique where two software engineers collaborate on a piece of software simultaneously. In an office, this is done at a single workstation where the two engineers sit side by side. Remotely, this is done through a communications channel like Zoom, Hangouts, or Teams, and a collaborative IDE like the Live Share extension for Visual Studio.
The two engineers each take on a role when pair programming. One engineer is the driver who writes the code and makes tactical decisions. The other is the navigator, who reviews the code on the go, gives directions, and stays focused on more strategic decisions. Unless one engineer is much more experienced than the other, both engineers should frequently switch roles to stay engaged and share the different workloads equally.
Pair programming is a controversial topic because it doesn't work in every scenario. It's not something you can simply start doing without considering how to do it. It's a skill that takes some effort to get good at. But the benefits of pair programming are genuine.
First, it improves the quality of your software. A meta-analysis found that pair programming leads to higher-quality software when compared with solo programming. This makes intuitive sense, because you have two sets of eyes looking at the same code at the same time.
Second, pair programming speeds up knowledge transfer between engineers. There will always be differences between how you program and how someone else programs, even for the simplest of applications. You'll always learn something new by watching someone else program and being able to ask questions about why they did something a particular way.
Third, when done correctly, pair programming ensures that engineers are intimately up-to-date with the entire codebase. No engineer works on a piece of code entirely on their own. Instead, they work together with other engineers and, in the navigator role, have to consider how any particular feature fits within the larger codebase.
Fourth, pair programming helps to quickly onboard new team members. When a new engineer joins a company, it can take a while before they're familiar with the codebase. Not only does pair programming speed up this process, but the engineers will be able to hit the ground running with the help of someone who's already familiar with the codebase.
Let's start with when you shouldn't do pair programming:
Pair programming is the most effective in the following scenarios:
Pair programming isn't necessarily a must-do. But as long as the two engineers communicate properly, set good objectives for every session, and take frequent breaks, it can be a great tool in an organization's toolbox to improve the quality of its code.