Pair programming, also known as pairing, paired programming, or programming in pairs, refers to a programming method where two to more team members get together to watch the same screen and solve the same problem in a collaborative way. Because we run in a highly collaborative environment, we use this methodology to mentor junior developers, help each other when we get stuck (regardless of expertise), or we want to discuss the best approach for a feature.
Here are the basics of pair programming methodology:
- Be ready to use your communication skills. This is all about sharing ideas and discussing the best approach to solve a common problem.
- Make sure that everyone is comfortable working. If the team involves more than two people in front of a single small display, it might not be really comfortable. If you’re working at an office, try to have a big display or two displays so everyone can see clearly.
If you’re working remotely, a good solution would be to work with a shared desktop or use a remote pair programming IDE plugin for Visual Studio Code, but my personal preference is just the screen-sharing feature in Slack.
- Start by presenting the problem and making sure everyone understands it.
- Do not invite unwilling developers to take part in this practice. Brainstorming needs active and open brains, not forced or under pressure.
- Keep the schedule simple. It’s not necessary to be super formal. You can encourage the team to pair up and work on some item that’s solvable in a reasonable period of time. After that, every pair could present and the whole team could wrap solved items.
- Motivate teammates to alternate roles frequently. This is a back-and-forth activity and it wouldn’t help developers if there’s always one person taking the drive.
- Once you’re done, meet up with team members and ask how they felt about it, what worked well, what didn’t, and what could be improved.
Advantages of pair programming
Knowledge is shared instantly. Every team member discusses at the moment of coding and understands the approach taken to solve the problem.
Shared responsibility. Every team member takes responsibility for what the code produces, good or bad, because they were all part of the thinking and coding process.
Code structure, the code structure is decided by all the team members.
The learning process is fast and intense. The team leader will share not only his knowledge and experience to solve the problem in the most effective way but also IDE shortcuts and tips to tackle similar problems, like software architecture, testing strategies, etc.
Fast (instant!) feedback between team members can make the Code Review faster.
Pair programming disadvantages
It could be inefficient in terms of time, especially if the team is just starting to consolidate or they’re not experienced enough with the stack and/or tools.
During this time the goal is to learn. Once the team is consolidated after a couple of weeks, the pair programming process gets faster and more efficient.
Another possible disadvantage is that the whole team has to be synchronized when facing the problem and working remotely from different time zones may complicate the logistics of this. It may not be as time effective for async and remote first companies.
Is pair programming effective?
I’d say that pair programming is super time-effective when you have an already consolidated team.
Let’s say that we have to solve a full stack feature, there will always be one developer more experienced or expert than others in that specific area. But what usually happens within teams is that one person is better at taking decisions, another is better in databases, and another is better in the front-end; the team leader knows each member’s skills and lets everyone participate in this process. This will undoubtedly make problem-solving faster.
It’s very effective for mentoring junior developers by showing them the whole process and having them watch how problems are solved better when working as a team.
Based on my experience, this methodology helped me to understand the company’s workflow, and to level up my knowledge by seeing how my teammates work. Nowadays I still do pair programming with my partners to help each other get unstuck. When it comes to coding, keep this phrase: “Unity is strength… when there is teamwork and collaboration, wonderful things can be achieved.” by Mattie Stepanek
Let’s remember that more than developers we’re human beings, and this kind of group process helps the interaction between team members, improves communication skills, and lets us get to know each other while working. In conclusion, pair programming can be super effective for solving problems, but it goes even further: it fosters a stronger relationship between team members through the sharing of knowledge.