Pairing up for programming

 

Summary

Pair programming is one of the most contentious practices within Extreme Programming. Does it really work?

Events

IBM Technology Conference & Expo 2012
May 23, 2012

Convention Centre B2 Room at 22nd Floor, Centara Grand @ Central World, 999/99 Rama I Road, Pathumwan, Bangkok 10330

Echelon 2012
June 11 and 12, 2012

University Cultural Centre, National University of Singapore

Startup Asia Jakarta 2012
June 7 and 8, 2012

12th Floor, Annex Building, Wisma Nusantara Complex, Jl. M.H. Thamrin No. 59 Jakarta 10350, Indonesia

MMA Forum Singapore
April 23-25, 2012

Grand Hyatt Singapore

Pair programming is one of the most contentious practices within Extreme Programming - both supporters and detractors can become quite emotional. So what is pair programming, and why do people become so emotional about it?

Laurie Williams describes pair programming as “a style of programming in which two programmers work side-by-side at one computer, continually collaborating on the same design, algorithm, code or test”. From this description it should be clear that pair programming is about more than simply the typing of the program itself, and I personally think that “pair development” would be a much better description of the activity.

Pair programming is not about one person simply watching what another person is doing– in effective pairing, the partners are often working at different levels of abstraction, one person concerned with the nitty gritty details of writing code to support the immediate goal, the other thinking of the big picture and of what to do next, and the partners are switching between these roles frequently. It’s an intense, rigorous and often tiring activity, that creates considered, high quality code.

The emotion quotient
Most of the emotion associated with opposition to pair programming arises because pair programming challenges the common social conventions of software development.

The traditional view of programming is that it consists of long periods of time spent in isolation, during which the programmer enters a “flow” and only interacts with the computer and their own mental models. As a result, programming has tended to be more appealing to introverts who liked to minimise social interactions, and less appealing to extroverts who wanted to collaborate minute-to-minute.

Certainly these are generalisations, but it’s important to acknowledge that there are programmers who simply don’t want to work side-by-side with someone else, and whose job satisfaction will certainly be affected by something like pair programming.

Opposition to pair programming also takes less emotional expression, generally framed around the idea that having two people working at one machine must inherently take twice as long as having them working independently and then merging their work.

This would certainly be true if the limiting factor in software development was how fast we could type programs, but as Kent Beck has observed, if this was the case we’d give every programmer a copy of Mavis Beacon (touching typing tutoring software).

I can’t touch type myself, and I’ve never asked someone their typing speed in an interview, so it’s doubtful this is our primary constraint. Rather, software development is an intellectual activity, which benefits from clarity of expression and the collaborative development of ideas, and pair programming helps in both these areas.

Another misconception is that the success pair programming should be measured solely in terms of the quantity of software that’s produced. When two people partner there are at least three outcomes:

  • the software
  • shared understanding of the application (the business domain, the design and the implementation)
  • skills transfer

The proportions of these change depending on the balance and dynamics of the pair, but all three are usually present to some extent. When an experienced programmer pairs with a novice, the pair may not produce any more software than the experienced programmer might have produced alone, but the novice will certainly have learned a great deal about the application and about programming in general. The sum of two
Compare this to leaving the two to work independently – we might get more software (though we might want to be very cautious about the quality of the novice’s work), but we get very little knowledge or skill transfer. If we have these two people on the same team, pairing seems to be a preferable way to spend their time.

On the other hand, two experienced people might find that there’s little skill transfer involved in their pairing, but that having them working at different levels of abstraction on the same problem lets them produce a solution faster, with fewer defects.

Another objective of pair programming is to spread knowledge of the application design and implementation as widely as possible.

This is achieved by rotating pairing, so that everyone on the team pairs with everyone else over time, and any particular part of the application is worked on by as many people as possible. In this environment, bad code doesn’t live very long because it’s exposed to many sets of eyes (which is similar to one of the principles behind open source development), and when design sessions come around the team benefits from everyone’s contributions, without needing to rely on just the one person that’s familiar with some particular part of the application.

There are also a number of other benefits to pair programming:

  • immediate, continuous code review.
  • working with someone increases accountability and discipline. It’s much harder to be slack when someone is watching!
  • two programmers are unlikely to have the same weaknesses or blindspots, so we get a strong solution.
  • pairs spend a lot less time going down blind alleys, since one person in the pair inevitably gets bored and wants to ask for help.

The last two points in this list are particularly true when pairs are rotating regularly. Of course, there are plenty of ways to do something that looks like pair programming but that fails to achieve, or subverts, these benefits.

If you don’t rotate pairs then you get programming cliques, and minimise knowledge and skill transfer. Some companies use pair programming as an excuse to eliminate personal space (we only need one desk and computer for every two programmers, right?), which ignores the human needs of programmers.

Expecting programmers to pair eight hours a day is also unrealistic – the continual interaction of pairing forces precision and clarity, but is also tiring, and there are always non development tasks to do as well.

Empirical evidence tells us that pair programming is an effective technique for improving software quality and lowering development time, but it’s not suitable for every programmer, and it needs to be implemented in a considered manner to be effective.

Steve Hayes is the Software Development Manager at Internet Business Systems (IBS). IBS provides agile methods consulting and development services, and browser hosted solutions to the financial services industry.

Talkback

Add your opinion

In order to post a comment, you need to be registered. (Sign In or register below)

Post your comment

ZDNet Asia Live

Integration, focused investments to propel Windows Phone - ZDNet Asia http://t.co/7sZi6Dhb

RT @zdnetasia: Homegrown smartphone OSes gaining favor in China. http://t.co/lL8KbccW

Big data acquisitions pave way to fast, effective innovation - ZDNet Asia http://t.co/ky8YgPAn #Bigdata #analytics via @ciropuglisi

Big data acquisitions pave way to fast, effective innovation - ZDNet Asia: Big data acquisition... http://t.co/r6taCmG1 #ITNews #BigData

Big data acquisitions pave way to fast, effective innovation - Zd Net http://t.co/d9k21ro5: David G... http://t.co/4JgaOz8g #bigdata #sna

Big data acquisitions pave way to fast, effective innovation - Zd Net http://t.co/fbori8UQ: Incr... http://t.co/nuEeUbj7 #ITNews #BigData

Big data acquisitions pave way to fast, effective innovation - ZDNet Asia http://t.co/iFQ74xYI #Bigdata #analytics

@ChemarieMonica : Integration, focused investments to propel Windows Phone - ZDNet As... http://t.co/ZVPDpbxH http://t.co/1QrdIsaV #tech

China social media companies have global potential
http://t.co/p8fkRbfD Chinese social media companies such as #Renren and #Sina might...

China social media companies have global potential
http://t.co/Y3x1qBI1 Chinese social media companies such as #Renren and #Sina might...

#radio Radio United Kingdom by EnjoyIT 1.0 http://t.co/YoV1dcFJ

#radio Radio United Kingdom by EnjoyIT 1.0 http://t.co/CbzcXPPO

Integration, focused investments to propel Windows Phone - ZDNet Asia: Gadget Helpline (blo... http://t.co/JZwEJCen http://t.co/KpTZdvuO

'Scramble' among vendors to acquire #bigdata co.s to bolster product offerings, manpower and market position. http://t.co/YWjgqj4r #in

Homegrown smartphone OSes gaining favor in China thanks to integration with local online services: IDC http://t.co/PJFx58yp #in

So much as we know , MTK6575 extremely integrated frequency1GHz ARM Cortex-A9 processor, the superiority of 3G / HSPA Modem, and help the...

1 day ago by y15822137359 on 5 SaaS adoption speed bumps to avoid

I reckon your view: "CRM is strategy, not software", if a company replicating the approach uses in ERP implementation into CRM, what they...

2 days ago by wykoong on Gartner: Mobile CRM gives better ROI than social

This video will teach you about the Excel fill handle but also provide you with a workook to download... http://www.youtube.com/watch?v=...

3 days ago by TradeBrother on A quick fill handle trick for Microsoft Excel

waiting...

5 days ago by eapete on What should count in a company's market value?

Boy, you've opened a can of worms now.

Wait for the rants & raves.

5 days ago by eapete on What should count in a company's market value?

I was puzzling before this whether to replicate the success formula we executed for a financial institute, and come out with a standard s...

5 days ago by wykoong on Drop the egos, copy ideas, then innovate