NELKINDA SOFTWARE CRAFT

Pair Programming

Pair programming is a practice helpful for knowledge sharing, improve team collaboration and communication, helps in team-building, get immediate feedback, code review. Pair programming is a practice that addresses technical collaboration. Applying practice is a choice. Practice needs time to develop. When you developed that practice you will enjoy its benefits.

Author:
Shweta Sadawarte, Software Craftsperson at Nelkinda Software Craft Pvt Ltd
First Published:
by NNelkinda Software Craft Private Limited
Last Modified:
by Shweta Sadawarte
Approximate reading time:

1 Origin

Pair Programming term is from Extreme Programming. XP states many coding, development and business practices to improve overall software development lifecycle. Practices like Pair Programming, TDD, BDD, code reviews, customer involvement, etc.

2 Definition

Pair programming is an agile software development technique in which two programmers work together at one workstation. One, the driver, writes code while the other, the observer or navigator, reviews each line of code as it is typed in. The two programmers switch roles frequently.
Pair Programming from the Wikipedia

3 Benefits of Pair Programming

4 Types of Pair Programming

4.1 Driver-Navigator

In this type of pair programming, one person has control of the keyboard. That person is responsible for writing the code. The other person is the navigator. Navigators job is to pay attention to the code written by the driver and provide the right direction by guiding. Usually, the navigator should be a more experienced/Expert person and the driver is less experienced/Novice. The pair should swap roles frequently. Otherwise, after sometime navigator loses his focus and only the driver is focused on the coding part.

4.2 Ping-Pong

In Ping Pong Pairing both persons are writing code frequently. For that, it is recommended to have two sets of input devices which mean two keyboards and two mouses in order to avoid context switching.

There are two ways in Ping Pong Pairing:

In one of the way, one person writes the test then the other person has to make that test to pass. In this way, one person always acts as a tester and one as a developer.

Example: Person 1: Writes the test
Person 2: Make the test pass/green
Person 1: Writes the test
Person 2: Make the test pass/green

In another way, one person writes the test then the other person has to make that test to pass, then they are responsible for writing the next test. Both people get to write and code.

Example: Person 1: Writes the test
Person 2: Make the test pass/green. Write the next test
Person 1: Make the test pass/green. Write the next test
Person 2: Make the test pass/green. Write the next test

5 Variants

5.1 Expert-expert

Expert-expert pairing is effective and gives the highest productivity. We can expect the highest quality of work.

5.2 Expert-novice

Expert-novice pairing gives many opportunities for the novice to learn from the expert.

5.3 Novice–novice

Novice–novice pairing is recommended to use when two novices are working independently. This type of pairing is usually avoided as both are a novice and so it is less effective.

6 Myth

Ineffective: People think pair programming is ineffective as two-person/programmers working on the same piece of code. Instead, if two persons work on different features/modules for a week, then we will have twice as many features. For sure we will have many features but in that case, we also need code review from other team members to ensure code quality. Means all the features are not yet ready to ship. We will have to wait till code review.

An online survey says 96% of people enjoy their work more than when they are pairing rather than programming alone and they were more confident in their solutions. Also, the resulting code has about 15% fewer defects.
Williams, Laurie; Kessler, Robert R.; Cunningham, Ward; Jeffries, Ron (2000). “Strengthening the case for pair programming.”IEEE Software.

Velocity decreases and slows down team: Individual velocity decreases in pair programming. But you should see team velocity rather than individual velocity. As different competency people are pairing there is knowledge transfer which helps further in your projects.

7 Pair Programming is extensively used in Coderetreat

Pair programming is extensively used in Coderetreat workshops. It is a good opportunity to introduce effective software development practices in this type of event. Mostly for students, novice person it is the first time they have introduced to the pair-programming practice. Where they will be paired with strangers (outside of the organization). You can see the maximum benefit of pair programming in Coderetreat as people are working on the same problem statement whole day but with different pairs. In each iteration, they can try different languages, learn good programming practices, extending their comfort zone. At the end of a coderetreat retrospective, it is quite common to get the feedback from first-timers that they didn’t expect working in a pair can be so productive and fun.

8 Similar concept - Mob programming

Mob programming is a software development approach where the whole team works on the same thing, at the same time, in the same space, and at the same computer.

9 Summary

To get the benefit of pair programming you need to understand when and how much to do pair programming. Implementing good practices by doing it in the right environment is necessary to get maximum return. Neither overdo it nor under do it.