Pair programming

Pair programming agile software development, mob programming, pair-programming roles, pair coding techniques

Pair programming is an agile software development technique originating from Extreme Programming – XP that involves two developers building the same code while using one single computer, solving the same problem and switching roles frequently. The two people have the roles of driver and navigator, where the driver is the one typing the code and the navigator is the one talking, reviewing the code, suggesting improvements and fixing errors.

While reviewing, the observer also considers the strategic direction of the work, coming up with ideas for improvements and likely future problems to address, which is intended to free the driver to focus all attention on the tactical aspects of completing the current task, using the observer as a safety net and guide.

Pair programming is a collaborative effort that involves a lot of communication between the driver and the navigator as they discuss approaches and solve issues that might be difficult for a single developer to detect. The two developers regularly take turns in rotating the roles of coding or reviewing and check each other’s work as they go, which keeps both developers alert and engaged.

Pair programming advantages

  • Positive impact on the source code
  • Fewer bugs introduced
  • Knowledge sharing
  • Better team cohesion
  • Improved focus and coordination

Main pair coding techniques

  • Ping Pong – performed in conjunction with Test-Driven Development, one person writes a test, the other person makes the test pass, each member alternates between writing tests and passing tests
  • Driver-Navigator – one person driving (or typing) and the other navigating, driver carries out the navigator’s instructions, but has the opportunity to make corrections or ask for clarification, driver and navigator regularly switch roles every 15 minutes or so
  • Unstructured Pairing – free-flowing technique with turn-taking between driver and navigator occurring as and when it makes sense

Mob programming

Mob programming is synchronous group coding where more than two developers are building the same code while using a single computer. It can be also viewed as pair-programming taken to extreme levels and a new role comes along with driver and navigator, which is called mobber and is the one handling the research part of the work.

Participants in mob programming rotate through the following roles:

  • A small group of developers discuss alternative implementations and select the best option
  • An individual developer listens to the mob’s discussion and communicates instructions to the driver
  • An individual developer converts the navigator’s instructions into code
  • An individual developer keeps the mob’s discussion on task and tells the group when roles should switch

Pair programming best practices

  • Consistent communication
  • Switch roles consistently
  • Pair up carefully
  • Use a familiar development environment
  • Submit code frequently
  • Ask for clarification when needed
  • Take breaks when needed

Agile development practices