:Pair programming

{{short description|Collaborative technique for software development}}

File:Wocintech (microsoft) - 61 (25926639341).jpg

File:Pair Programming at Chitika.JPG

Pair programming is a software development technique in which two programmers work together at one workstation. One, the driver, writes code while the other, the observer or navigator,{{cite conference |last1=Williams |first1=Laurie|author1-link=Laurie Williams (software engineer) |title=Integrating pair programming into a software development process |pages=27–36 |doi=10.1109/CSEE.2001.913816 |conference=14th Conference on Software Engineering Education and Training |date=February 19–20, 2001 |location=Charlotte |isbn=0-7695-1059-0 |quote=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.}} 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 is intended to free the driver to focus all of their attention on the "tactical" aspects of completing the current task, using the observer as a safety net and guide.

Economics

Pair programming increases the man-hours required to deliver code compared to programmers working individually. However, the resulting code has fewer defects. Along with code development time, other factors like field support costs and quality assurance also figure into the return on investment. Pair programming might theoretically offset these expenses by reducing defects in the programs.{{Cite journal|last1=Cockburn|first1=Alistair|last2=Williams|first2=Laurie|author2-link=Laurie Williams (software engineer)|title=The Costs and Benefits of Pair Programming|journal=Proceedings of the First International Conference on Extreme Programming and Flexible Processes in Software Engineering (XP2000)|author-link=Alistair Cockburn|year=2000|url=http://collaboration.csc.ncsu.edu/laurie/Papers/XPSardinia.PDF}}

In addition to preventing mistakes as they are made, other intangible benefits may exist. For example, the courtesy of rejecting phone calls or other distractions while working together, taking fewer breaks at agreed-upon intervals or sharing breaks to return phone calls (but returning to work quickly since someone is waiting). One member of the team might have more focus and help drive or awaken the other if they lose focus, and that role might periodically change. One member might know about a topic or technique that the other does not, which might eliminate delays to finding or testing a solution, or allow for a better solution, thus effectively expanding the skill set, knowledge, and experience of a programmer as compared to working alone. Each of these intangible benefits, and many more, may be challenging to accurately measure but can contribute to more efficient working hours.{{citation needed|date=April 2022}}

Design quality

A system with two programmers possesses greater potential for the generation of more diverse solutions to problems for three reasons:

  1. the programmers bring different prior experiences to the task;
  2. they may assess information relevant to the task in different ways;
  3. they stand in different relationships to the problem by their functional roles.

In an attempt to share goals and plans, the programmers must overtly negotiate a shared course of action when a conflict arises between them. In doing so, they consider a larger number of ways of solving the problem than a single programmer alone might do. This significantly improves the design quality of the program as it reduces the chances of selecting a poor method.{{cite book |first1=Nick V. |last1=Flor |first2=Edwin L. |last2=Hutchins |chapter=Analyzing Distributed Cognition in Software Teams: A Case Study of Team Programming During Perfective Software Maintenance |pages=36–64 |chapter-url={{Google books|KT_bpSSJBgcC|page=36|plainurl=yes}} |editor1-first=Jürgen |editor1-last=Koenemann-Belliveau |editor2-first=Thomas G. |editor2-last=Moher |editor3-first=Scott P. |editor3-last=Robertson |year=1991 |title=Empirical Studies of Programmers: Fourth Workshop |publisher=Ablex |isbn=978-0-89391-856-9 }}

Satisfaction

In an online survey of pair programmers from 2000, 96% of programmers stated that they enjoyed working more while pair programming than programming alone. Furthermore, 95% said that they were more confident in their work when they pair programmed. However, as the survey was among self-selected pair programmers, it did not account for programmers who were forced to pair program.{{cite journal |last1=Williams |first1=Laurie|author1-link=Laurie Williams (software engineer) |last2=Kessler |first2=Robert R. |last3=Cunningham |first3=Ward |last4=Jeffries |first4=Ron |title=Strengthening the case for pair programming |journal=IEEE Software |volume=17 |issue=4 |year=2000 |pages=19–25 |doi=10.1109/52.854064 |url=http://sunnyday.mit.edu/16.355/williams.pdf |citeseerx=10.1.1.33.5248 }}

Learning

Knowledge is constantly shared between pair programmers, whether in the industry or in a classroom. Many sources suggest that students show higher confidence when programming in pairs, and many learn whether it be from tips on programming language rules to overall design skills.{{cite journal |last1=Williams |first1=Laurie|author1-link=Laurie Williams (software engineer) |last2=Upchurch |first2=Richard L. |title=In support of student pair programming |journal=ACM SIGCSE Bulletin |volume=33 |issue=1 |year=2001 |pages=327–31 |doi=10.1145/366413.364614 |doi-access=free }} In "promiscuous pairing", each programmer communicates and works with all the other programmers on the team rather than pairing only with one partner, which causes knowledge of the system to spread throughout the whole team. Pair programming allows programmers to examine their partner's code and provide feedback, which is necessary to increase their own ability to develop monitoring mechanisms for their own learning activities.

Team-building and communication

File:Pair programming 1.jpg

Pair programming allows team members to share quickly, making them less likely to have agendas hidden from each other. This helps pair programmers learn to communicate more easily. "This raises the communication bandwidth and frequency within the project, increasing overall information flow within the team."

Studies

There are both empirical studies and meta-analyses of pair programming. The empirical studies tend to examine the level of productivity and the quality of the code, while meta-analyses may focus on biases introduced by the process of testing and publishing.

A meta-analysis found pairs typically consider more design alternatives than programmers working alone, arrive at simpler, more maintainable designs, and catch design defects earlier. However, it raised concerns that its findings may have been influenced by "signs of publication bias among published studies on pair programming." It concluded that "pair programming is not uniformly beneficial or effective."{{cite journal

| last = Hannay

| first = Jo E.

|author2=Tore Dybå |author3=Erik Arisholm |author4=Dag I.K. Sjøberg

| title = The Effectiveness of Pair Programming: A Meta-Analysis

| journal = Information and Software Technology

| volume = 51

| issue = 7

| pages = 1110–1122

|date=July 2009

| doi = 10.1016/j.infsof.2009.02.001}}

Although pair programmers may complete a task faster than a solo programmer, the total number of man-hours increases. A manager would have 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 by project and 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, and for novices as compared to experts.{{cite journal

| last = Lui

| first = Kim Man

| title = Pair programming productivity: Novice–novice vs. expert–expert

| journal = International Journal of Human–Computer Studies

| volume = 64

| issue = 9

| pages = 915–925

| date = September 2006

| doi = 10.1016/j.ijhcs.2006.04.010

| url = http://www.cs.utexas.edu/users/mckinley/305j/pair-hcs-2006.pdf

| access-date = 2012-11-18

| citeseerx = 10.1.1.364.2159

| archive-url = https://web.archive.org/web/20110720105133/http://www.cs.utexas.edu/users/mckinley/305j/pair-hcs-2006.pdf

| archive-date = 2011-07-20

| url-status = dead

}} Pair programming could be helpful for attaining high quality and correctness on complex programming tasks, but it would also increase the development effort (cost) significantly.

On simple tasks, which the pair already fully understands, pairing results in a net drop in productivity.{{cite journal

| last = Arisholm

| first = Erik

|author2=Hans Gallis |author3=Tore Dybå |author4=Dag I.K. Sjøberg

| title = Evaluating Pair Programming with Respect to System Complexity and Programmer Expertise

| journal = IEEE Transactions on Software Engineering

| volume = 33

| issue = 2

| pages = 65–86

|date=February 2007

| doi = 10.1109/TSE.2007.17

| s2cid = 9889035

| url = http://simula.no/research/se/publications/Arisholm.2006.2/simula_pdf_file

| access-date = 2008-07-21

| archive-url = https://web.archive.org/web/20101029033020/http://simula.no/research/se/publications/Arisholm.2006.2/simula_pdf_file

| archive-date = 2010-10-29

| url-status = dead}} It may reduce the code development time but also risks reducing the quality of the program. Productivity can also drop when novice–novice pairing is used without sufficient availability of a mentor to coach them.{{cite web|last=Stephens|first=Matt |author2=Doug Rosenberg |title=Will Pair Programming Really Improve Your Project?|url=http://www.methodsandtools.com/archive/archive.php?id=10| access-date = 28 May 2011}}

A study of programmers using AI assistance tools such as GitHub Copilot found that while some programmers conceived of AI assistance as similar to pair programming, in practice the use of such tools is very different in terms of the programmer experience, with the human programmer having to transition repeatedly between driver and navigator roles.{{cite journal |last1=Sarkar |first1=Advait |last2=Gordon |first2=Andrew D. |last3=Negreanu |first3=Carina |last4=Poelitz |first4=Christian |last5=Ragavan |first5=Sruti S. |last6=Zorn |first6=Ben |title=What is it like to program with artificial intelligence? |journal=Psychology of Programming Interest Group |date=2022 |url=https://www.ppig.org/papers/2022-ppig-33rd-sarkar/ |access-date=27 March 2023}}

Indicators of non-performance

There are indicators that a pair is not performing well:{{opinion|date=May 2021}}

  • Disengagement may present as one of the members physically withdraws away from the keyboard, accesses email, or even falls asleep.
  • The "Watch the Master" phenomenon can arise if one member is more experienced than the other. In this situation, the junior member may take the observer role, deferring to the senior member of the pair for the majority of coding activity. This can easily lead to disengagement.

Pairing variations

;Expert–expert

:Expert–expert pairing may seem to be the obvious choice for the highest productivity and can produce great results, but it often yields little insight into new ways to solve problems, as both parties are unlikely to question established practices.

;Expert–novice

:Expert–novice pairing creates many opportunities for the expert to mentor the novice. This pairing can also introduce new ideas, as the novice is more likely to question established practices. The expert, now required to explain established practices, is also more likely to question them. However, in this pairing, an intimidated novice may passively "watch the master" and hesitate to participate meaningfully. Also, some experts may not have the patience needed to allow constructive novice participation.{{cite book|title=Pair Programming Illuminated |author1=Williams, L. |author1-link=Laurie Williams (software engineer) |author2=Kessler, R. |name-list-style=amp |publisher=Addison-Wesley Professional |location=Boston |date=2003|url=https://books.google.com/books?id=LRQhdlrKNE8C|isbn=9780201745764 }}

;Novice–novice

:Novice–novice pairing can produce results significantly better than two novices working independently, although this practice is generally discouraged because it is harder for novices to develop good habits without a proper role model.

Remote pair programming

Remote pair programming, also known as virtual pair programming or distributed pair programming, is pair programming in which the two programmers are in different locations,{{cite journal |last1=Flor |first1=Nick V. |title=Globally distributed software development and pair programming |journal=Communications of the ACM |volume=49 |issue=10 |year=2006 |pages=57–8 |doi=10.1145/1164394.1164421 |s2cid=8963421 }} 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 verbal communication resulting in confusion and conflicts over such things as who "has the keyboard".{{cite journal

| last = Schümmer

| first = Till

|author2=Stephan Lukosch

| title = Understanding Tools and Practices for Distributed Pair Programming

| journal = Journal of Universal Computer Science

| volume = 15

| issue = 16

| pages = 3101–3125

|date=September 2009

| url = http://www.jucs.org/jucs_15_16/understanding_tools_and_practices/jucs_15_16_3101_3125_schuemmer.pdf

| access-date = 2010-04-30}}

Tool support could be provided by:

  • Whole-screen sharing software[http://blogs.pathf.com/agileajax/2007/09/pair-programmin.html Agile Ajax: Pair Programming with VNC] {{webarchive|url=https://web.archive.org/web/20080402003711/http://blogs.pathf.com/agileajax/2007/09/pair-programmin.html |date=2008-04-02 }}{{self-published source|date=April 2016}}[http://weblogs.asp.net/jcogley/archive/2004/10/13/242117.aspx Pair Programming – The Ultimate Setup and the other options we tried. – Jonathan Cogley's Blog]{{self-published inline|date=April 2016}}
  • Terminal multiplexers
  • Specialized distributed editing tools
  • Audio chat programs or VoIP software could be helpful when the screen sharing software does not provide two-way audio capability. Use of headsets keep the programmers' hands free
  • Cloud development environments
  • Collaborative pair programming services

See also

References

{{reflist|30em}}