Used by agile teams all over the world, pair programming is a valuable system of working that uses collaboration between two developers to produce faster, more efficient, more inspired work.
Particularly useful for large complex projects, pair programming came into popular use in the early 2000s. In recent years it has gained more traction and, while it’s not useful for every kind of project and is not without its challenges, there’s definitely a whole lot to be gained from this close collaborative style of coding.
The definition of pair programming
Pair programming is when two programmers work together on the same computer. One, the ‘driver,’ works on writing the code while the other, the ‘navigator’ reviews the lines of code as they’re typed. The two regularly swap places as the work progresses.
As the pair work, they constantly interact, sharing ideas, discussing problems and finding solutions. Traditionally, pair programming is done side by side. Recently though, with the rise of remote working, remote pair programming has become more popular, with tools such as Code Together, Floobits, Use Together and Tuple increasingly adopted.
Benefits of pair programming
It produces cleaner code with less errors
Good code is concise code. It should be lean, short and efficient. When working in pairs, programmers can check and modify the code in real time, shortening the feedback loop and making corrections at a more efficient and effective rate. Having two people solve problems at various times, with one constantly monitoring the coding, means fewer coding mistakes.
The split responsibilities also enable better focus. The ‘driver’ is free to concentrate on writing code in a fluent fashion, without having to constantly check back over what they’ve written. Meanwhile, the ‘navigator’ is focused on finding errors, while keeping an overall picture of the project in mind.
You can share knowledge throughout the team
Having one specialist involved in creating a program is risky. If this person leaves, they take the knowledge with them, making the program effectively useless.
Pair programming doubles down on the knowledge, ensuring more than one person has the key to the safe. It’s useful to think of it like that – a backup key, in case one is lost.
It builds soft skills
As pair programming is such a socially interactive way of working, it stands to reason that the soft skills of the programmers will improve. Collaborating on a project in such close quarters requires listening skills, the ability to get ideas across and, most crucially, the ability to work as a team.
Gaining a deep appreciation for the values of communication and teamwork is a hugely important learning experience, one that is hard to teach on the job. Pair programming is one of the best ways for team members to develop this appreciation.
It fosters creativity
Constant interaction between the two programmers creates an environment that’s better suited for being creative. Programmers can bounce ideas off each other, working towards better solutions to problems quicker and more effectively.
Too often, solo programmers can find themselves at a dead end, stuck in a rut with no solution in sight. Through sharing ideas out loud, a pair of programmers can overcome challenges a lot quicker.
What challenges does pair programming produce?
It can be time consuming
Two programmers working on a project might be faster than one programmer, but it’s not as fast as two programmers working on the project separately. For some companies, particularly startups for whom speed is vital, pair programming can be too much of a drain on productivity.
In the short term, at least. There is an argument that, as the resulting code will be cleaner, with less errors and less need to revisit and maintain it, time and effort will be saved in the long run. Either way, finding a way to ensure pair programming works within an organised, well-structured system that doesn’t result in delays is a challenge.
It can create conflict
Pair programming works wonderfully well if the pair are suited – equal abilities and same levels of experience, with a chemistry that means they work well together.
If the pair aren’t well suited to work together, things can quickly take a turn for the worse. Having a programmer who can’t keep up with or complement the other’s workflow can cause problems. Not only will it slow down the project, but it will negatively affect the morale of the programmer who is carrying the weight.
It’s also vital that both programmers come to the pair programming project motivated and fully engaged. Pair programming is a highly social and interactive way to work, so they should both be prepared to vocalise thoughts and opinions, and be comfortable working closely with another member of the team.
This is why programmers should never be randomly paired. There should be plenty of consideration about the ability of the pair to work together effectively.
It can interrupt the ‘flow’
For many programmers, coding is about getting into a flow state, where everything comes together. Others like to sit with their own thoughts, reflecting quietly on their work and coming to solutions through their own methods.
In these situations, pair programming can be seen as disruptive. Still, for those programmers with the right mindset who are willing to collaborate towards a common goal, pair programming can actually find a new kind of flow, improving efficiency and productivity, while building solid relationships within a team.