Strengthening the Case for Pair Programming
Total Page:16
File Type:pdf, Size:1020Kb
focusprocess diversity Strengthening the Case for Pair Programming The software Laurie Williams, North Carolina State University industry has Robert R. Kessler, University of Utah practiced pair programming—two Ward Cunningham, Cunningham & Cunningham programmers Ron Jeffries working side by side at one or years, programmers in industry have claimed that by working computer on the collaboratively, they have produced higher-quality software prod- same problem— ucts in shorter amounts of time. But their evidence was anecdotal with great success and subjective: “It works” or “It feels right.” To validate these for years. But F people who haven’t claims, we have gathered quantitative evidence showing that pair program- tried it often reject ming—two programmers working side by side at one computer on the same the idea as a waste of resources. The authors design, algorithm, code, or test—does in- programming skill from novice to expert. deed improve software quality and reduce demonstrate that time to market. Additionally, student and Earlier Observations using pair professional programmers consistently find In 1998, Temple University professor programming in pair programming more enjoyable than John Nosek reported on his study of 15 the software working alone. full-time, experienced programmers work- development Yet most who have not tried and tested ing for a maximum of 45 minutes on a chal- process yields pair programming reject the idea as a re- lenging problem important to their organi- dundant, wasteful use of programming re- zation. In their own environments and with better products in sources: “Why would I put two people on a their own equipment, five worked individu- less time—and job that just one can do? I can’t afford to do ally and 10 worked collaboratively in five happier, that!” But we have found, as Larry Con- pairs. The conditions and materials were more confident stantine wrote, that “Two programmers in the same for both the experimental (team) programmers. tandem is not redundancy; it’s a direct route and control (individual) groups. A two- to greater efficiency and better quality.”1 sided t-test showed that the study provided Our supportive evidence comes from statistically significant results. Combining professional programmers and from ad- their time, the pairs spent 60% more min- vanced undergraduate students who partic- utes on the task. Because they worked in ipated in a structured experiment. The ex- tandem, however, they completed the task perimental results show that programming 40% faster than the control groups, and pairs develop better code faster with only a produced better algorithms and code.2 minimal increase in prerelease programmer Most of the programmers were initially hours. These results apply to all levels of skeptical of the value of collaborating and 0740-7459/00/$10.00 © 2000 IEEE July/August 2000 IEEE SOFTWARE 19 You know what I like about pair programming? First, it’s something that has been shown to help produce quality products. But, it’s also something that you can easily add to your pro- cess that people actually want to do. It’s a conceptually small thing to add, as opposed to having an overblown methodology shoved down your throat. And, when times get tough, you wouldn’t likely forget to do pair programming or decide to drop it “just to get done.” I just think the idea of working together is a winner. —Chuck Allison, Consulting Editor, C/C++ Users Journal (in a conversation with Laurie Williams) thought it would not be an enjoyable at all times and wholly share the ownership process. But, according to Nosek, “To the of the work product, whether it is a morn- surprise of the managers and participants, ing’s effort or an entire project. all the teams outperformed the individual Ideally, pair programmers will always programmers, enjoyed the problem-solving work together. But reality—illness, time process more, and had greater confidence in conflicts, or even efficiency—dictates that at their solutions.”2 times the pair must split. Experienced pair Pair programming is not new. In 1995, programmers prioritize the parts of the de- Larry Constantine reported observing pairs of velopment cycle, deciding which are most programmers producing code faster and freer important to work on together and which of bugs than ever before.2 The same year, Jim can be done separately. They must also de- Coplien published what he called the devel- cide what to do with the independently de- oping-in-pairs organizational pattern.3 veloped work when they reunite. When a In 1996, Smalltalk code developer and larger group adopts pair programming as consultant Kent Beck, with authors Ward the normal way of working, the long-term Cunningham and Ron Jeffries, began devel- continuity of a particular pair becomes less oping the Extreme Programming software important. By pairing regularly with all development methodology (see the sidebar). members of the group, an individual pro- XP is now practiced by programmers grammer maintains sufficient general aware- worldwide. A significant part of XP is pair ness to substitute for a missing partner at a programming, and people who practice XP moment’s notice. are the largest known group of pair pro- Unanimously, the pair programmers we grammers. The XP methodology’s success have observed agree that pair analysis and rate is so impressive that it has aroused the pair design are critical to success. That is, curiosity of many software engineering re- two brains are better than one when per- searchers and consultants. The XP founders forming analysis and design. Pairs consider credit much of this success to the use of pair many more possible solutions to a problem programming by all XP programmers, ex- and converge more quickly on which solu- perts and novices alike. tion to implement. According to researchers Nick Flor and Edwin Hutchins, the feed- The Development Cycle back, debate, and idea exchange between In pair programming, two programmers partners significantly decrease the probabil- jointly produce one artifact (design, algo- ity of proceeding with a bad design.4 Col- rithm, code). The two programmers are like laborators often can perform tasks that are a unified, intelligent organism working with too challenging for one to do alone. In an one mind, responsible for every aspect of anonymous online survey (http://limes.cs. this artifact. One partner, the driver, con- utah.edu/questionnaire/questionnaire.htm), trols the pencil, mouse, or keyboard and one professional programmer reflected, “It writes the code. The other partner continu- is a powerful technique as there are two ously and actively observes the driver’s brains concentrating on the same problem work, watching for defects, thinking of al- all the time. It forces one to concentrate ternatives, looking up resources, and con- fully on the problem at hand.” sidering strategic implications. The partners While one partner is busy typing or writ- deliberately switch roles periodically. Both ing down the design, the other partner can are equal, active participants in the process continuously review the design and think 20 IEEE SOFTWARE July/August 2000 What Is eXtreme Programming? the discipline of writing tests first and the complementary, eXtreme Programming is a software development method though quite distinct, discipline of writing simple solutions. that favors informal and immediate communication over the de- I Developers expect their intentions to show clearly in the tailed and specific work products required by many traditional code they write and refactor their code and other’s if neces- design methods. Pair programming fits well within XP for rea- sary to achieve this result. A partner who has been tracking sons ranging from quality and productivity to vocabulary devel- the programmer’s intention is well equipped to judge the opment and cross training. XP relies on pair programming so program’s expressiveness. heavily that it insists all production code be written by pairs. I Developers continuously integrate their work into a single XP consists of a dozen practices appropriate for small to development thread, testing its health by running compre- midsize teams developing software with vague or changing re- hensive unit tests. With each integration, the pair releases quirements. The methodology copes with change by delivering ownership of their work to the whole team. At this point, dif- software early and often and by absorbing feedback into the ferent pairings can form if another combination of talent is development culture and ultimately into the code. more appropriate for the next piece of work. Several XP practices involve pair programming: 1 I Developers work on only one requirement at a time, usually To learn more, see Kent Beck’s book, or consult the eXtreme the one with the greatest business value as established by Programming Roadmap at xp.c2.com, where a lively commu- the customer. Pairs form to interpret requirements or to place nity debates each XP practice. their implementation within the code base. I Developers create unit tests for the code’s expected behavior Reference and then write the simplest, most straightforward implemen- 1. K. Beck, eXtreme Programming Explained: Embrace Change, tations that pass their tests. Pairs help each other maintain Addison Wesley Longman, Reading, Mass., 2000. more strategically about its implications. Programmers view pair analysis and de- Will it run into a dead end? Is there is a bet- sign as more critical than pair implementa- ter strategy? Thus, pair programming pre- tion. Pairs report that they sometimes work vents design defects or removes them almost on implementation individually, usually the as soon as they hit the paper. A further ben- rote, routine, or simple coding phases of a efit is the elimination of design tunnel vi- project. They find that doing this type of pro- sion—making a design decision and sticking gramming individually is more effective.