Collaborating on a project in pairs has many advantages, whether programming a project or any other undertaking. Two sets of eyes usually see more than one: Pair programming minimizes the risk of errors. While one programmer writes the code, the other examines it and focuses all their attention on finding errors. It’s often difficult to spot your own mistakes. A co-worker can often find discrepancies much faster.
Another big advantage is that communication fosters creativity: By constantly interacting, the programming duo comes up with ideas that might not have occurred to one person alone. When the two partners share ideas, they come up with better solutions to problems in less time. One coder working alone might be satisfied with the first solution that comes along, but in pair programming, co-workers always have to justify their decisions to the other programmer. The other person might have a different view of the problem and might not be satisfied with the proposed solution. The resulting discussion often leads to ideas for much better code.
Ultimately, good code means lean code: Experience shows that source code created through pair programming is often shorter and more efficient. This means that fewer resources are required to maintain and modify the code later.
As mentioned, you can also use this technique to enable expert programmers to share their knowledge with less experienced team members. That way you can benefit from the main advantage of pair programming – high-quality code – and simultaneously use the method for training teams.
However, pair programming can be time-consuming: Although two programmers working together might be much faster than one person working alone, they’re not as fast as two programmers working separately. In other words, this method will either slow down projects or require you to hire more staff, which in turn will increase costs. However, advocates of pair programming assume that the initial extra work will pay off in the end. Since the resulting code contains fewer errors and is generally better structured, it requires much less maintenance.
Another possible drawback: Pair programming is good for team building, but only if the two programmers can get along. They have to interact so closely that personal problems between them will either slow down the project or result in a major escalation. Programmers should never be placed together randomly. Although it’s ideal if every programmer has been paired up with every other team member at some point, it won’t work unless the whole team gets along well together.