Pair programming is a method that can bring many benefits both to programmers and the whole company they work for. If you are wondering why and when it is worth using it, and also why it still has many opponents – we invite you to read this article.
What is pair programming?
Pair programming is one of programming methods. It consists of common work of two programmers who use the same computer and work on one code. It was invented by Kent Beck and is a part of the Extreme Programming methodology, created to provide the highest quality software.
Pair programming is a work of two programmers who use the same computer and write one code
So, how does pair programming work? In this method, one of the developers, who plays a “driver” role, writes the code, while the second one (“navigator”) observes and analyzes every line of written code, searches for possible errors and – if necessary – suggests other, better solutions. Moreover, the navigator often tells and instructs the driver how and why to write a particular line of code.
Why many programmers don’ like pair programming?
Pair programming arouses much controversy among developers. The main reason is that a person in the role of a driver may feel uncomfortable when someone analyzes every element of his work. Some people find it stressful and it may contribute to their work being less effective.
Pair programming can also have negative effects when it comes to relationships in a team. When two employees work very closely together and at some point, they will have differing opinions about what solution is better – then conflicts may arise.
Another issue that is mentioned by opponents of this method is a waste of time and money. A navigator, who only supervises the correctness of the code, could also write his own code at that time, so separately they would be able to do more. As we know, programmers’ salaries are not low, so every hour that could have been “spared” is of extreme importance here.
The benefits of pair programming
Many well-known companies from the IT sector, such as Stack Overflow, use this method. They realize that the benefits of pair programming far outweigh its costs. Below you will find the most important advantages of it.
1. Increasing efficiency
Most studies on the effectiveness of pair programming confirm that it has a very positive effect on the programmers’ productivity. It was confirmed as early as in 1998 by John T. Nosek, who, in his article The Case for Collaborative Programming, showed that programmers working together on one code need about 30% less time than those coding alone.
2. Reducing errors
Due to the fact that two people take care of the quality of the code, the risk of errors is significantly reduced. According to the study The Costs and Benefits of Pair Programming from 2013, this practice extends the work on the code by only 15%, and reduces errors by 15% instead.
3. The ability to share knowledge
It’s not surprising that pair programming is particularly beneficial for beginner programmers who can work with more experienced colleagues. In the case of pairing juniors with seniors, it is a great opportunity for young programmers who can quickly learn new things. However, this is actually a win-win situation, because even less experienced people can ask good questions or suggest better solutions. Even for a senior developer, it can also be a chance to prove themselves as a mentor who can share their knowledge with others.
4. Support in the onboarding process
You can also use pair programming when you want to show your new employees your way of working and the projects you participate in. Even a few hours of working together on a project will allow them to better understand the system. In this case, it is really a time-saving method, because thanks to the fact that new employees can learn and ask questions, they will not have to waste many hours to understand the code on their own.
5. An effective recruitment method
Pair programming is a good solution not only for efficient implementation of IT projects. It also allows you to quickly and effectively estimate the skills of people applying for a job to your company. Verification, meaning how people write the code and they deal with encountered problems is a great way to select the best candidate for the job.
Pair programming – our opinion
Pair programming is also a method that is practiced in our team. Therefore, we asked Krzysztof Kodrzycki – Software Developer at WEBSENSA for sharing his opinion.
Pair programming can be a very useful programming method, especially for more difficult tasks that do not have an obvious solution. However, it doesn’t work in every case. Firstly, because of the deadlines set by the management, which often don’t allow two programmers to complete together one task. And secondly, because some people need peace and quiet when programming, so working with another programmer can make them ineffective.
In this method I really appreciate specific code review, which is performed during code writing, as well as the ability to learn quickly by observing how another person solves a particular problem. An additional advantage of pair programming is a great chance to immediately catch errors and the ability to ask questions about the code that is just being written.
Apart from working in the company, I had the opportunity to use pair programming on various hackathons. During pair programming I would pay attention to the communication between programmers (if someone has a question they should ask it immediately) and changing the role from “driver” to “navigator” (and vice versa) in constant time intervals.