Pair Programming

From AgileMe
Jump to navigation Jump to search


Pair programming is an XP technique where a pair of programmers work together with a single keyboard and mouse to write code, and promotes enhanced code quality, code production on complex issues and development disciplines that would otherwise be too easy to omit with solo coding.

Using only one keyboard and mouse, this promotes a natural split of roles to include one person coding (driver) and the other watching and evaluating (navigator). Experienced pair programmers may swap the keyboard back and forth and exchange the roles intuitively as they work towards a code solution.

Benefits

  • Improved performance when dealing with complex coding problems - two programmers work in a collaborative approach to produce solutions that would not normally be solved easily as with solo coding.
  • Reduced code complexity, as pair programmers will look for elegant solutions that are simple but effective.
  • Enhanced discipline - the pair naturally look to keep each other on track and retain the best practice disciplines
  • Auto-code review - the pair work together with one constantly evaluating new code, this produces instant feedback and critique, which is to the benefit of the code quality
  • Survivability - with two developers working on the same piece of code they understand the code constructs in detail and so can cover for each other during times of absence or reallocation to other projects
  • Works with other XP practices - other XP practices such as Test Driven Development for example work well to complement pair programming

Challenges

  • Compatible pairs - not everyone is cut out to be a pair programmer and there are individuals who find it difficult to trade and work in a collaborative approach when dealing with code
  • Mismatched experience - if a pair do not have a matching experience level, then the activity of pair programming may be reduced to coding and watching rather than a collaborative exchange of mutually respected ideas.
  • Cost - performance improves when dealing with complex issues, and pair programming produces a high return on the investment, however, for mundane or simple coding problems there may well be a sub-optimal cost and a reduced return on the investment

Patterns

  • Research and Development - when breaking new ground with unfamiliar technology such as new coding languages and new platforms for example, a pair programming approach can yield improved performance to provide elegant solutions. This is down to two people working together to resolve a common problem and where they collaboratively share and trade ideas in a creative setting to resolve the complexity of something new.
  • Master and Apprentice - there may be cases where one member of a pair is more experienced than the other, which if within a certain tollerance, can upskill an apprentice to a mutually respected level. N.B. Pair programming should not be used as a tutoring session, but can be used as a mentoring session where some experience already exists.

Adaptations

  • Pair testing - why not let the testers have a go and keep each other on track when devising test scripts and expected behaviour
  • Programming and Testing - when using test driven development, there may be scope to pair a tester with a developer, where the developer can provide the tech skills and the tester can provide the analytical skills to produce good test scripts
  • Pair architect - why not let the architects loose on complex system designs to work collaboratively to arrive at elegant solutions

See Also

References

  1. Extreme Programming Explained: Embrace Change, Beck K, Andres C, 2005