General

What is Pair Programming and Why Do Developers Do It?

What is Pair Programming and Why Do Developers Do It?Preview: What is Pair Programming and Why Do Developers Do It?

New to the world of programming? You might not be familiar with the term pair programming – yet. But one thing's for sure, you will be by the end of this post!

What is pair programming?

Pair programming is a common software development technique where two developers work on the same code, together, at the same computer.

One developer takes the role of 'driver' – this person takes ownership of the keyboard and mouse and physically writes the code. Meanwhile, the other developer – the 'navigator' – concentrates on the 'big picture' and the direction the code is going, reviewing and revising the code the driver is writing.

What is Pair Programming and Why Do Developers Do It?Preview: What is Pair Programming and Why Do Developers Do It?

Why is pair programming great?

1. Share knowledge

The wealth of experience around you is something many developers don't make the most of. Your peers are one of the most valuable resources you have. Our students are almost always surprised by the sheer amount they can learn from each other when pair programming – even those who were sceptical about it when they first started the course.

2. Maintain the stream of development

Pair programming partially removes the temptation to procrastinate. Let's face it – we're human! Left to our own devices, it's all too easy to switch off and let the mental cogs stop whirring. Pairing with somebody means you can both spur each other on and lend each other moral support and motivation.

3. Make fewer mistakes

When driving as a pair, you'd be surprised how many mistakes the navigator picks up – even when you are both confident developers. Catching mistakes swiftly saves time fixing things during testing, or worse, after the feature has gone live!

What is Pair Programming and Why Do Developers Do It?Preview: What is Pair Programming and Why Do Developers Do It?

4. Write better code

Pair programming leads to more concise, readable and 'DRY' code. DRY stands for Don't Repeat Yourself, and alludes to the good practice of writing repeatable code blocks. By the simple nature of watching each other code, developers are more likely to feel accountable for the quality of code they write. The navigator should also make suggestions as to how to write the code according to best practice. Recent studies have shown that pairs write shorter programmes than individual developers, indicating superior design.

5. Get stuck less

Every developer has become stuck on a problem while coding. To be even bolder, I might claim that pretty much every developer out there has become stuck dozens, if not hundreds, of times. That's a really normal thing, but sometimes it can waste time. Quite often, having somebody there to point you in the right direction can save a huge amount of time. Likewise, the driver might know plenty about one problem the navigator doesn't – and vice versa. Everyone's a winner!

6. Code faster

By relaying information backwards and forwards between the two halves of the pair, you can make more progress faster than you would on your own. This means more can be achieved at a higher quality in less time. It is a little bit counterintuitive that two people can do more together than they could if they were both coding separately, but interestingly studies have found that whilst pair programming takes longer per person, it actually only takes around 15% longer – and produces 15% fewer defects, which more than offsets the cost.

7. Better collaboration

Working together improves people's ability to work together. Information flows more freely between team members and the dynamic of the team improves. Pair programming also means that more people understand how different parts of the software work, which avoids problems when somebody is ill, on leave or decides to leave the business.

8. More seamless onboarding 

What better way to get to grips with a company's systems, methods and practices than to pair with someone who has worked there longer? Not only does this give you the opportunity to be guided around the unfamiliar codebase by somebody who knows it well, but you'll also have the opportunity to learn more coding techniques and language or technology features from your pairs – and get up to speed and progress your career faster!

Introduction to Programming

We hope you enjoyed this introduction to pair programming. Want to fast-track your coding knowledge with Northcoders? Sign up for our beginner's coding course, in Manchester or Leeds and get to grips with some more coding essentials in workshops led by our teaching team! Â