Pair Programming: Best Practices, Tips, Benefits & More
Tags: pairprogramming, bestpractices, programming
Published: 2023-05-23 22:03:33

# In this post

- [Motivation](#motivation)
- [Our methodology](#our-methodology)
- [Best practices](#best-practices)
- [Benefits](#benefits)
- [Things to avoid](#things-to-avoid)
- [How the DE Team reflects the LTV Core Values in the pair programming sessions](#how-the-DE-Team-reflects-the-LTV-Core-Values-in-the-pair-programming-sessions)

---
# Motivation <a name="motivation">

This blog post will focus on the LTVco data engineering team’s pair programming practices. The data engineering team (DE) handles the transmission and transformation of data from one place to another. We would like to share our methodology for structured pair programming that this team observes and share the benefits from these sessions that we see. This team plans pair programming sessions at least twice a week. Pair programming can be helpful in the following situations:

- When learning a new technology or programming language to speed up the learning process. The more experienced developer can help guide the less experienced one.
- When working on a tight deadline to increase productivity and deliver code faster.
- When working on a critical or complex project with a high degree of uncertainty. Pair programming reduces the risk of errors and increases the chance of finding a solution to a problem.

---
# Our methodology <a name="our-methodology">

## Preparation
The first in a pair programming session is to define the pairs with a quick stand-up meeting. The pairs are matched based on the following points:

- For the pairs to work efficiently, their task needs to be well-defined.
- There must be a reason for them to be working together, such as working on similar tickets.
- We prefer to pair our Jr Engineers with Senior Engineers to facilitate knowledge transfer and training.
- It is important to consider if one of the pair members has more knowledge in a particular area so that they can complement each other, rather than just splitting the work between themselves and working separately.

## Session
- Define what’s expected to be done in the session. Both pairs should at least discuss this.
  - For example, define a mini-agenda for the PP Session, define what to expect and how a result can create a bifurcation, which way is the best to go, etc.
- Define the roles, who will be the navigator, and who will be the driver.
  - The one with the context or with more expertise about what is going to be worked on should assume the role of navigator.
  - The navigator should be guiding the session through verbal communication.
  - The navigator creates spaces and opportunities to encourage the analytic/creative skills of the driver and contribute to their learning instead of just providing solutions or giving instructions of what to do.
  - The one with less context or expertise about what is going to be worked on, should assume the role of driver.
  - The driver most of the time asks, codes and is practical.
  - The lead is in charge of setting the session objectives, moderating the time and taking into account how much should be invested in each objective.
  - When both pairs have similar levels of context and expertise, each one can assume a hybrid role between driver and navigator to split the job to be done, and both work at the same time.
  - The navigator typically takes the lead of the session, but the driver can also lead.
  - The roles might change at some point in the session based on the objectives.
- If the session is going to be 2 hours or longer, it is important to build in 10-15 minute breaks to prevent saturation..
  - The break time could be adjusted as needed, but it’s best to define breaks ahead of time and abide by the schedule.

---
# Best practices <a name="best-practices">

## Constant communication
You should actively communicate with your partner at all times. The goal of a pair programming session is not to code alone, so be present and participate with your partner.

## Role switching (when possible)
To ensure that both programmers working in a pair are equally committed and effective, the driver and navigator should swap roles regularly. Otherwise, the navigator may quickly get bored and stop concentrating on their task, while the driver would run the risk of burnout. Frequent role-switching also makes both software developers feel equally responsible for the quality of the code they create together.

# Benefits <a name="benefits">

## Knowledge transfer
Teaching and knowledge transfer by an expert or senior engineer on a particular project or area can help participant(s) to go deeper into the subject matter through pair programming. This also creates the opportunity to learn not only about code but also about the workflow of the other person, the other person’s workflows, tricks, best practices for solving tasks and how to address problems.

## Forge bonds
Take a moment to talk about your day, your weekend and how everything is going. Encouraging pairs to have a relaxed and enjoyable time together will lead to happier employees.

## Time management
A task could be solved in less time thanks to the help of the pair. Also, the more experience the team gains, the higher productivity will be.

## Lose the fear of the unknown
One of the biggest benefits is losing the fear of the unknown. Feeling supported raises confidence and removes anxiety. This helps a lot when training new team members.

## Code quality improvement
Pair programming decreases the likelihood of writing sloppy code. With two people working together as one, the output is usually more well-thought-out and organized. This is reflected as higher-quality code that is easier to maintain.

---
# Things to avoid <a name="things-to-avoid">

## Overcontrol
Overcontrol often happens when one developer is more experienced (or better versed) and tries to impose his/her point-of-view, dictate code, and strictly control the workflow. This leads to one of the pair members doing all the work and the other one just observing without participating. Overcontrol might undermine (or even eliminate) the aforementioned benefits of pair programming.

## Distractions
Distractions like phone notifications, messages or deliveries are always a risk, especially for remote workers. If not properly managed, the pairs may lose focus on some occasions. Be present and respectful with your partner, but also wise about how you allocate your time.

## Extremely long sessions
Don’t do super long sessions that can last for hours. Take breaks and schedule time for other activities that are not programming.

---
# How the DE Team reflects the LTV Core Values in the pair programming sessions <a name="how-the-DE-Team-reflects-the-LTV-Core-Values-in-the-pair-programming-sessions">

![LTVs Core Values](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/66duqwbd14521q3exze0.jpg)

## Try, fail, learn, repeat
It’s rare for anything to work perfectly on the first try. In the DE team, we are used to motivating ourselves to keep pushing and trying again. Paired programming means there’s an extra set of eyes on every problem, making the troubleshooting process much easier. Working as a team, a pair can iterate, troubleshoot and adjust easily until they finally achieve success. Troubleshooting in pair programming sessions leads to two or more people learning at the same time how to face and solve a new problem. This knowledge is later shared with all the team members.

## Teach each other to fish
This is one of the core values and benefits of pair programming. By just promoting pair programming we enforce this core value. Besides this, we always try to focus on knowledge transfer in each of our sessions to make the most out of them.

## No job is above or beneath you
No matter how complex a task could be, or how little knowledge you might have about it, instead of assigning you something easier, we encourage you to face the challenge with the support of someone that can help you along the process.

## Question everything, respectfully
There are no wrong or bad questions. In the pair programming sessions anyone can ask anything respectfully, and the team works to create an environment where nobody feels threatened or fearful about not knowing something. If it is necessary, a member of other pairs or even someone from another team is welcome to join the session just to eliminate any doubt.

## Be all in
This is a value that is always present in every one of the team members. But especially in pair programming sessions we are fully committed to making the most of the opportunity due to all the benefits and how useful they are. It is always fun and motivating to work side by side with one of your co-workers!

---

Interested in working with us? Have a look at our [careers page](https://www.ltvco.com/careers/) and reach out to us if you would like to be a part of our team!


![Author](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q3zdckaud2u1rrma7oeo.png)