Pair programming is one of those widely known programming methodologies. Most of us would certainly nod in agreement when its benefits are described. By pair programming we simply mean that two developers work side by side, one is the ‘driver’ that writes the code while the other is the ‘observer’ or ‘navigator’ in charge or reviewing the code that gets written. The former ends up having a more tactical approach, concentrating on the current line of code being written; while the later tends to think more strategically about the problem.
In this brief article I’ll describe some of the benefits that can be derived from it as well as simple ways it can be introduced into your current workflow in order to achieve some immediate benefits. It’s worth noting that it’s effectiveness is reduces is there is a big gap in the knowledge of the two participants. In that case, pair programming becomes more of a teacher-student situation, which has its own pros and cons.
1. Getting up to speed with a new codebase
When a new member joins an existing project or team, it can take some time (depending on size) to get fully comfortable with the existing codebase. Pair programming can speed up this process substantially as the existing team member can provide context as well as check the assumptions that the new team member is making. Furthermore, existing bugs might be found through this process.
2. Producing higher quality code
Working in isolation means that are assumptions are seldom checked, or are checked at a later stage if code reviews are in place. With pair programming, chances are that we can end up with a better architecture as both peers discuss the best way to structure a problem and negotiate a common approach. Furthermore, the final solution might be a blending of two different yet complementary approaches.
3. Solving a complex problem faster
When faced with a complex problem we can occasionally get stuck trying to find a way around it. Although we will eventually find a satisfactory solution, we might end up wasting a significant amount of time. Perhaps a little time spend pair programming with a more experienced college can help us overcome the block and find an effective solution to our conundrum. We might even have the advantage of ending up with a higher quality solution.
4. Job interviews
The traditional job interview tends to involve a coding test or programming questions. Sometimes a small, self-contained project will put together by the candidate. This artificial project tends to be over-engineered as the candidate seeks to show how she would architecture an application or how many of the more esoteric features of the language they know. Pair programming can provide a better alternative: The candidate doesn’t work on an artificial, isolated code-base and the employer can get a better idea if the candidate would be a better fit as they work with existing members of the team. The candidate would be driver, while one of the existing employees would review their code. In this way, they can understand the candidate’s train of thought as she writes the code.
We’ve seen here some of the ways that pair programming can easily be put into practise. Hopefully, this gives you an idea on how you can try it out.