One of the most valuable techniques to accelerate your way of thinking like an experienced developer.
As a junior engineer getting ready to enter the workforce, pair programming is likely one of the first techniques you will encounter on the job as your teammates get you up to speed on a project. You may also pair program during your engineering interview, which will give the interviewer a sense of how you work, your technical skill base, and your approach to problem solving.
Pair programming involves two programmers working together at one station. You will share one screen, keyboard, and mouse. The programmer who sits at the keyboard and writes code is called the driver, while the programmer who reviews the code as it is typed in is called the navigator. The driver and navigator switch roles from every few minutes to up to every half hour. “Well functioning teams can have a fluid process to change driver-navigator [roles that] is usually informal,” said Thomas Stiehm, CTO of Coveros, Inc.
Different development teams will vary in how often they pair program. At some companies, teams will pair program only when developers have a specific reason to do so—like when they need to quickly train new team members. Other companies will encourage their developers to pair up regularly as a way to distribute knowledge of the code base, help each other when they get stuck on a problem, and to collaborate when making important design decisions at the beginning of a project.
While developers wouldn’t approach an entire project through pair programming, “pairing any amount can be valuable,” said Christian Nelson, VP of Engineering at Carbon Five. “It promotes collaborative problem solving, leading to the creation of thorough, resilient, and thoughtful solutions.” This primer will provide you an overview on what pair programming is, and how to make the most from your sessions.
Pair programming is also called “programming out loud,” because at least the driver (if not both team members) are expected to keep up running commentary on the code as it is being written. The technique contributes to a team’s better understanding of the code, which helps them to make fewer mistakes and move faster through the development cycle. Teams find value in pair programming when they need to
introduce new developers to the team’s processes, style guide, and coding guidelines. When joining a company, you could be bombarded with a ton of new information, and working closely with an experienced developer can make it easier for you to catch up and to ask direct questions. Your partner can show you how a part of the code base works, as well as new tools and efficient workflows. “It can be really helpful for opening up new ways of thinking,” said Sam Gavis-Hughson, founder and interview coach at Byte by Byte. “It’s also really helpful to see what kinds of little keyboard shortcuts and tricks other people are using to be more efficient.”
consider their work as it is being written, rather than reviewing it after it’s completed. As the driver writes code, the navigator reviews it in real time and provides input on how to make improvements to the design quality. This helps the pair to think more intentionally about their work, catch mistakes, and to produce higher quality code that can reinforce the team’s quality standards.
While code and design review are processes that usually occur after code is already written, pair programming allows for the team to “think about the code and how it fits into the overall solution as it is being built,” Stiehm said. “It often helps to have multiple [people] thinking about the implications of code decisions as it is being written, to think of all the things that might happen while the code is running.”
“Pair programming works best when the pairs constantly change [roles],” said Uladzimir Sinkevich, head of Java development at ScienceSoft. “This enables instant knowledge transfer throughout the team and helps to avoid situations when the knowledge of a certain code piece is locked within one team member.” Development teams are often in flux, and programmers come and go for many reasons. Pair programming helps to disperse knowledge of key pieces of code throughout the team, and helps them to avoid situations where a team member leaves with unfinished work that is difficult for another developer to pick up and understand.
When you are a new(ish) developer, it will be helpful for you to know how to make the most out of pair programming with an experienced team member. “Regardless of the role taken at the moment (whether you’re a driver or a navigator), each programmer should be an active participant of the process,” Sinkevich said.
1.Use it as a learning opportunity You may feel intimidated when you are paired with an experienced team member, but remember that you are partners. “It’s going to be stressful at first, but realize that the purpose is not to judge each other. The purpose is to collaborate. Everyone brings unique skills to the table,” said Gavis-Hughson.
You can gain insight into your team member’s way of thinking and communication style. “Use pairing to learn how the code base works, learn why decisions were made, and learn how to think like an experienced software developer,” Stiehm said.
2.Drive as much as you can and ask questions Pair programming loses its effectiveness when one team member becomes disengaged. You may be tempted to take on a passive role when you are working with a programmer who is more experienced than you are, but “pair programming is not about one person doing all the [work] and another one just sitting by,” Sinkevich said.
As a navigator, you can stay engaged by following your partner’s reasoning and asking questions. “Also realize that you can often learn a lot more by being the one at the keyboard,” Gavis-Hughson said.
“Try to drive as much as possible,” Stiehm recommended.
3.Communicate with your partner Keep in mind that different people and circumstances will require you to adapt your pairing style, so communication is key. For example, as you gain experience as a developer, you may pair program remotely, which will involve you and your partner working from different locations through collaborative software. Your experience in a virtual pairing will naturally be different than when you work in-person with your team members.
One of the most effective ways to improve your efforts is to have dedicated time for a pairing retrospective. “Don’t be afraid to ask for what you need,” Nelson said. “Talking about pairing helps build trust, improves collaboration, and strengthens communication between you and your programming partner.”
When you and your partner work well together, pair programming can lead to a stronger, more knowledgeable team that produces high-quality code. Especially as you are starting out, pair programming can be one of the most valuable techniques to help you adjust to your learning curve and accelerate your way of thinking like an experienced developer.
Hannah H. Kim is a freelance writer. You can find her work on AngelList, Fastcompany, and Increment.