- Pair programming
-
Pair programming is an agile software development technique in which two programmers work together at one workstation. One, the driver, types in code while the other, the observer (or navigator[1]), reviews each line of code as it is typed in. The two programmers switch roles frequently.
While reviewing, the observer also considers the strategic direction of the work, coming up with ideas for improvements and likely future problems to address. This frees the driver to focus all of his or her attention on the "tactical" aspects of completing the current task, using the observer as a safety net and guide.
Contents
Costs and benefits
Some studies have found that programmers working in pairs produce shorter programs, with better designs and fewer bugs, than programmers working alone.[2] Studies have found reduction in defect rates of 15% to 50%, varying depending on programmer experience and task complexity.[3][4] Pairs typically consider more design alternatives than programmers working solo, and arrive at simpler, more-maintainable designs; they also catch design defects early.[5] Pairs usually complete work faster than one programmer assigned to the same task. Pairs often find that seemingly "impossible" problems become easy or even quick, or at least possible to solve when they work together.[2][6]
However, a 2007 meta-analysis concluded that "pair programming is not uniformly beneficial or effective" because many other factors besides the choice of whether to use pair programming have large effects on the outcome of a programming task.[7] The meta-study found that pair programming tends to reduce development time somewhat and produces marginal positive effects on code quality, but that pair programming requires significantly more developer effort; that is, it is significantly more expensive than solo programming. The authors suggest that studies of pair programming suffer from publication bias whereby studies that would not show that pair programming is beneficial were either not undertaken, not submitted for publication, or not accepted for publication. They conclude that "you cannot expect faster and better and cheaper."
Even though coding is often completed faster than when one programmer works alone, total programmer time (number of programmers × time spent) increases. A manager needs to balance faster completion of the work and reduced testing and debugging time against the higher cost of coding. The relative weight of these factors can vary from project to project and task to task. The benefit of pairing is greatest on tasks that the programmers do not fully understand before they begin: that is, challenging tasks that call for creativity and sophistication.[8] On simple tasks, which the pair already fully understands, pairing results in a net drop in productivity.[8][9] Productivity can also drop when novice-novice pairing is used without sufficient availability of a mentor to coach them.[10]
Knowledge passes between pair programmers as they work. They share knowledge of the specifics of the system, and they pick up programming techniques from each other.[2][11] New hires quickly pick up the practices of the team and learn the specifics of the system.[12] With "promiscuous pairing" – each programmer cycling through all the other programmers on the team rather than pairing only with one partner – knowledge of the system spreads throughout the whole team, reducing risk to management if one programmer leaves the team.[2]
Pairing usually brings improved discipline and time management. Programmers are less likely to skip writing unit tests, spend time web-surfing or on personal email,[13] or cut corners when they are working with a pair partner. The pair partner "keeps them honest".[14][15] People are more reluctant to interrupt a pair than they are to interrupt someone working alone.[16]
Additional benefits reported include increased morale[17] and greater confidence in the correctness of the code.[2]
Scientific studies
According to The Economist,
- "Laurie Williams of the University of Utah in Salt Lake City has shown that paired programmers are only 15% slower than two independent individual programmers, but produce 15% fewer bugs. (N.B.: The original study showed that 'error-free' code went from 70% to 85%; it may be more intuitive to call this a 50% decrease of errors, from 30% to 15%.) Since testing and debugging are often many times more costly than initial programming, this is an impressive result."[4]
The Williams et al. 2000 study showed an improvement in correctness of around 15% and a 20%–40% decrease in time, but between a 15% and 60% increase in effort—that is, total programmer-hours. Williams et al. 2000 also cites an earlier study (Nosek 1998) which also had a 40% decrease in time for a 60% increase in effort.
A study (Lui 2006) presents a rigorous scientific experiment in which novice–novice pairs against novice solos experience significantly greater productivity gains than expert–expert pairs against expert solos.[8]
A larger recent study (Arisholm et al. 2007) had 48% increase in correctness for complex systems, but no significant difference in time, whilst simple systems had 20% decrease in time, but no significant difference in correctness. Overall there was no general reduction in time or increase in correctness, but an overall 84% increase in effort.[9][18]
Lui, Chan, and Nosek (2008) shows that pair programming outperforms for design tasks.[19]
A full-scale meta-analysis of pair programming experimental studies, from before or during 2007, (Hannay et al. 2009) confirms "that you cannot expect faster and better and cheaper". Higher quality for complex tasks costs higher effort, reduced duration for simpler tasks comes with noticeably lower quality – the meta-analysis "suggests that pair programming is not uniformly beneficial or effective".[20]
Non-Performing Indications
There are a few indicators that a pair is not performing well:
- Disengagement – One of the members physically moves their chair away from the keyboard, or starts working on their email, etc. Sometimes this can be as extreme as one member falling asleep.
- Watch the Master – Sometimes one member will be more experienced than the other. There is a temptation to defer to the more senior member, and the less senior will be relegated to observer status. This will often lead to disengagement.
- Silence – Pairs cannot work together if they are not talking to each other.[21]
Variants
Remote pair programming
Remote pair programming, also known as virtual pair programming or distributed pair programming, is pair programming where the two programmers are in different locations,[22] working via a collaborative real-time editor, shared desktop, or a remote pair programming IDE plugin. Remote pairing introduces difficulties not present in face-to-face pairing, such as extra delays for coordination, depending more on "heavyweight" task-tracking tools instead of "lightweight" ones like index cards, and loss of non-verbal communication resulting in confusion and conflicts over such things as who "has the keyboard".[23]
Tool support is provided either by a screen sharing software (such as VNC or RealVNC[24] [25] [26] or the multi-display mode (-x) of the text-based GNU screen) or by specialized distributed editor tools (such as Gobby, Saros or XPairtise).
Ping pong pair programming
In ping pong pair programming, the observer writes a failing unit test, the driver modifies the code to pass the test. At this point, they swap roles and the original driver (as observer) writes a failing test. The original observer (now driver) modifies the code to get the new test to pass, and so on. This loop continues as long as either member of the pair is able to write failing unit tests for the other to implement. In general, this approach may take more time than the estimated plan.[27]
See also
External links
- wikiHow: How to Pair Program How-to guide; contains common wisdom on how to make pair programming work.
- PairWithUs A collection of videos showing pair programming in action.
Programs and plug-ins to support remote pair programming
- Eclipse Communication Framework Includes Cola, an Eclipse plug-in
- Saros An Eclipse plug-in
- XPairtise An Eclipse plug-in
- wave-vs.net Plug-in for Visual Studio
References
- ^ Williams, Laurie (2001). "Integrating Pair Programming into a Software Development Process" (PDF). 14th Conference on Software Engineering Education and Training: abstract. http://ieeexplore.ieee.org/Xplore/login.jsp?url=/iel5/7294/19720/00913816.pdf."One of the programmers, the driver, has control of the keyboard/mouse and actively implements the program. The other programmer, the observer, continuously observes the work of the driver to identify tactical (syntactic, spelling, etc.) defects, and also thinks strategically about the direction of the work."
- ^ a b c d e Cockburn, Alistair; Williams, Laurie (2000). "The Costs and Benefits of Pair Programming" (PDF). Proceedings of the First International Conference on Extreme Programming and Flexible Processes in Software Engineering (XP2000). http://collaboration.csc.ncsu.edu/laurie/Papers/XPSardinia.PDF.
- ^ Canfora, Gerardo; Aniello Cimitile, Felix Garcia, Mario Piattini, Corrado Aaron Visaggio (2007). "Evaluating performances of pair designing in industry" (PDF). The Journal of Systems and Software 80 (80): 1317–1327. doi:10.1016/j.jss.2006.11.004. http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.101.9212&rep=rep1&type=pdf. Retrieved 2010-06-14.
- ^ a b "Agility counts". The Economist. September 20, 2001. http://www.economist.com/displayStory.cfm?Story_ID=779429..
- ^ Williams, Laurie; Kessler, Robert (2003). Pair Programming Illuminated. Addison-Wesley. pp. 27–28. ISBN 0-201-74576-3. "With pair programming, 'four eyeballs are better than two,' and a momentous number of defects are prevented, removed right from the start. These continual reviews outperform traditional, formal reviews in their defect-removal speed."
- ^ Williams, Laurie; Kessler, Robert (2003). Pair Programming Illuminated. Addison-Wesley. pp. 26. ISBN 0-201-74576-3. "Collaborative teams consistently report that together they can evolve solutions to unruly or seemingly impossible problems. … The driver might actually be working out a design or implementing a part of the problem, realizing that he or she may ultimately come to a dead end in the problem resolution. The navigator, while watching the driver's partial design or implementation, begins thinking about the next step. When the driver hits the dead end, the navigator is often prepared to take over and lead the way. Often, the cycle continues until the problem is solved."
- ^ Hannay, Jo E.; Tore Dybå, Erik Arisholm, Dag I.K. Sjøberg (July 2009). "The Effectiveness of Pair Programming: A Meta-Analysis". Information and Software Technology 51 (7): 1110–1122. doi:10.1016/j.infsof.2009.02.001.
- ^ a b c Lui, Kim Man (September 2006). "Pair programming productivity: Novice-novice vs. expert-expert" (PDF). International Journal of Human-Computer Studies 64 (9): 915–925. doi:10.1016/j.ijhcs.2006.04.010. http://simula.no/research/se/publications/Arisholm.2006.2/simula_pdf_file. Retrieved 2008-07-21.[dead link]
- ^ a b Arisholm, Erik; Hans Gallis, Tore Dybå, Dag I.K. Sjøberg (February 2007). "Evaluating Pair Programming with Respect to System Complexity and Programmer Expertise". IEEE Transactions on Software Engineering 33 (2): 65–86. doi:10.1109/TSE.2007.17. http://simula.no/research/engineering/publications/Arisholm.2006.2/simula_pdf_file. Retrieved 2008-07-21.
- ^ Stephens, Matt; Doug Rosenberg. "Will Pair Programming Really Improve Your Project?". http://www.methodsandtools.com/archive/archive.php?id=10. Retrieved 28 May 2011.
- ^ Williams, Laurie; Kessler, Robert (2003). Pair Programming Illuminated. Addison-Wesley. pp. 29. ISBN 0-201-74576-3. "Knowledge is constantly being passed between partners, from tool usage tips to design and programming idioms. The partners take turns being the teacher and the student. Even unspoken skills and habits cross partners."
- ^ Williams, Laurie; Kessler, Robert (2003). Pair Programming Illuminated. Addison-Wesley. pp. 112. ISBN 0-201-74576-3. "[Expert-novice pairing] can even be valuable for novices who are novices only in the sense that they haven't been with their team for very long. … Watching and then doing with an expert by your side can greatly reduce the time it would require to learn 'the right way' of working with the team. It really helps when the newbie works with many of the experts (or with any team member) so he or she can learn about many different aspects of the system."
- ^ Williams, Laurie; Kessler, Robert (2003). Pair Programming Illuminated. Addison-Wesley. pp. 23. ISBN 0-201-74576-3. "Two people working in a pair treat their shared time as more valuable. They tend to cut phone calls short; they don't check e-mail messages or favorite Web pages; they don't waste each other's time." (Ward's Wiki 1999, contributed by Paul Chisholm).
- ^ Beck, Kent (2000). Extreme Programming Explained. Addison-Wesley. pp. 102. ISBN 201-61641-6."Under stress, people revert. They will skip writing tests. They will put off refactoring. They will avoid integrating. With your partner watching, though, chances are that even if you feel like blowing off one of these practices, your partner won't."
- ^ Williams, Laurie; Kessler, Robert (2003). Pair Programming Illuminated. Addison-Wesley. pp. 24. ISBN 0-201-74576-3."With any software development process there is a constant struggle to get the software engineers to follow the prescribed process. A benefit of pair programming is improved adherence to procedures and standards."
- ^ Williams, Laurie; Kessler, Robert (2003). Pair Programming Illuminated. Addison-Wesley. pp. 24. ISBN 0-201-74576-3."Others see us already working with someone else, and they leave us alone. The net effect is that we have bigger blocks of uninterrupted time, which is good for our mental state and our progress. It also reduces task-switching, which for some people generates a huge overhead."
- ^ Williams, Laurie; Kessler, Robert (2003). Pair Programming Illuminated. Addison-Wesley. pp. 21. ISBN 0-201-74576-3. "In our recent Web survey, we asked, 'What have you found beneficial about pair programming?' The single most common response was, 'It's a lot more fun!'"
- ^ Aranda, Jorge (2007-03-12). "Pair programming evaluated". http://catenary.wordpress.com/2007/03/12/pair-programming-evaluated/. Retrieved February 7, 2008.
- ^ Lui, Kim Man; Keith C. C. Chan, John Teofil Nosek (March/April 2008). "The Effect of Pairs in Program Design Tasks" (PDF). IEEE Transactions on Software Engineering 32 (2): 197–211. doi:10.1109/TSE.2007.70755. http://www.cpe.virginia.edu/Quals%20Papers%20Aug%2008/SoftEng.pdf. Retrieved 2008-07-21.[dead link]
- ^ Hannay, Jo E.; Tore Dybå, Erik Arisholm, Dag I.K. Sjøberg (July 2009). "The Effectiveness of Pair Programming: A Meta-Analysis". Information and Software Technology 51 (7): 1110–1122. doi:10.1016/j.infsof.2009.02.001.
- ^ http://www.agilesherpa.org/agile_coach/engineering_practices/pair_programming/
- ^ Flor, Nick (2006). Globally distributed software development and pair programming. Communication of the ACM, 49, 57-58.
- ^ Schümmer, Till; Stephan Lukosch (September 2009). "Understanding Tools and Practices for Distributed Pair Programming" (PDF). Journal of Universal Computer Science 15 (16): 3101–3125. http://www.jucs.org/jucs_15_16/understanding_tools_and_practices/jucs_15_16_3101_3125_schuemmer.pdf. Retrieved 2010-04-30.
- ^ Agile Ajax: Pair Programming with VNC
- ^ Pair Programming - The Ultimate Setup and the other options we tried. - Jonathan Cogley's Blog
- ^ Ola Lindberg › Computer ergonomics and pair programming
- ^ "PairProgrammingPingPongPattern". c2.com. http://www.c2.com/cgi/wiki?PairProgrammingPingPongPattern.
Categories:
Wikimedia Foundation. 2010.