TribalScale
Published in

TribalScale

Pair Programming: Or Does 1 + 1 = 3?

Written by: Don Stevenson, Agile Software Engineer, TribalScale

TL;DR Pair programming is an effective way to work together that increases enjoyment, productivity and quality of the code. When done well, everyone gains from the experience and the results are really like 1 + 1 = 3.

Photo by Alvaro Reyes on Unsplash

Humans generally tackle complex tasks more efficiently and effectively when working with a partner. I had experience with this from a young age: growing up, my father and I tackled diverse projects from home and car repair, to machining, woodworking and welding. Often my job was to hold the light in the garage, but he would always take the time to explain what he was doing and where appropriate, have me try the task at hand. He would often comment that just having me involved, “moral support” he would call it, was a real benefit to him.

As an adult, I’ve continued that spirit of repair and working on projects. My best work has been when working on projects with others, for example: building a cedar strip canoe and a bass guitar, learning to play guitar, and playing team sports.

Perhaps unsurprisingly, the benefits of teamwork also extend to the world of programming.

When I got into code, I was happy to discover pair programming. A large part of the reason I wanted to work at TribalScale was that I knew I would benefit from pairing and that I could share my experience with the team as well.

Pair Programming — What Is It?

At its core, pair programming is a way to develop and produce code where two programmers work together at one workstation. It works on the premise that one programmer will write the code, or drive, and the other will observe and navigate the activity of the driver. In best practices, the roles switch with a regular amount of frequency with some sources suggesting as much as every 20 to 30 minutes.

The driver’s main goal is to focus on tackling the challenge at hand. The observer should act as a safety net of sorts, helping to guide the driver with delivering the completed tasks in an efficient manner.

Why Do We Bother Pairing?

Studies show that pair programming leads to an increase in the amount, and arguably more important, the quality of the code produced when compared to the output of two programmers working independently. This increase in quality and quantity is directly beneficial to a company’s bottom line.

A second pair of eyes can help catch syntax errors. While developments in programming editors to include things like code linters and auto predict are undoubtedly beneficial, these kinds of software don’t do as well with conceptual problems in one’s code. Following code naming conventions, refactoring and page organization are just three examples of tasks that humans are able to tackle and software has yet to handle as efficiently. Just by working together, the role a navigator plays can easily lead to an increase in code quality and quantity.

Coding in pairs can help keep the focus on the activity at hand. The 21st century continues to increase the rate at which we all are inundated with distractions and interruptions, and the future is likely to continue in this trend. The driver is less likely to be as distracted by messages, emails, phone calls, etc. if the navigator can filter these communications by importance or relevance to the task at hand.

Team Building

By working together, pair programmers are in an environment that fosters communication about code. In explaining the choices or directions taken to solve a particular challenge, programmers benefit from articulating a problem in natural language. Through working together, the channels of communication are open for direct, frequent and more open communication while facing a challenge. By leaning on each other for help, pair programmers create trust and make meaningful relationships with one another.

It shouldn’t come as a surprise that this kind of interpersonal relationship building brings an increased sense of job satisfaction for both programmers involved. These team-building benefits alone make pair programming a worthwhile endeavour. In survey of student pair programmers from 2014, 93% of them stated that they enjoyed their work more than when they programmed alone and 84% said that they were more confident in their solutions when they pair programmed.

Three Kinds of Relationships

In pair programming, there tend to be three combinations of relationships between programmers. Each has its own attributes and benefits.

Expert with Expert — While this may be logically the strongest choice to produce quantity and quality code, this relation can sometimes fall short in producing novel solutions as both parties are more likely to be set in established work practices.

Novice with Expert — While the code output may not be as high as the above partnership, both programmers can gain valuable results in working with each other. The expert gets to explain coding practices and approaches to the novice. The novice is the obvious recipient of learning by observing and coding under the direction of the expert. The expert may gain novel insight into problems as novices are more likely to ask fundamental questions about why certain approaches are taken. These questions can lead to a reevaluation of the established practices, trying novel or different approaches, and better code is more likely to result.

Novice with NoviceAlthough both novice programmers report increased code quality and quantity, this relationship is more susceptible to less than optimal practices as neither programmer may have established successful practices.

Some Potential Pitfalls To Watch For

Each programmer has to buy-in to the idea of pair programming. Like any relationship, programmers have to work to support each other and offer both positive reinforcement and constructive criticism. If coding styles are very different, conflicts can arise in terms of deciding on the best approach. Also, not everyone is socially compatible with one another. Sometimes, one programmer may develop a reluctance to switch positions from driver or navigator which can lead to missed opportunities for learning. These considerations must be accounted for and taken seriously in order to foster an environment where pair programming can really work in a meaningful way.

Closing Thoughts

In the end, pair programming is just one approach to programming. As shown above, pair programming has many benefits to both parties in terms of learning, enjoyment, productivity, focus, and team building. In my own experiences with pair programming, I found that these dividends have paid many times over during my time at TribalScale. At the very least, I would recommend that everyone take time to do some pair programming, preferably at least a few times, and with programmers of differing skill sets, and see what kind of results it produces for them.

References

Chigona, W., & Pollock, M. (2008). Pair Programming for Information Systems Students New To Programming: Students’ Experiences and Teachers’ Challenges. PICMET 2008 Proceedings,1587–1594.

Faja, S. (2014). Evaluating Effectiveness of Pair Programming as a Teaching Tool in Programming Courses. Information Systems Education Journal, 12(6), 36-46.

McDowell, C., Werner, L., Bullock, H.E., Fernald, J. (2006). Pair Programming Improves Student Retention, Confidence, and Program Quality. Communication of the ACM,49(8), 90-95.

Muller, M. (2007). Do Programmers Pairs Make Different Mistakes than Solo Programmers? The Journal of Systems and Software, 80, 1460-1471.

Williams, L. & Kessler R. (2001). Experiments with Industry's "Pair-Programming" Model in the Computer Science Classroom. Computer Science Education, 11(1), 7-20.

Zacharis, N. Z. (2011). Measuring the Effects of Virtual Pair Programming in an Introductory Programming Java Course. IEEE Transactions on Education, 54(1), 168-170.

Don Stevenson is a Toronto-based Agile Software Engineer here at TribalScale. When he’s not working on code, he enjoys doing things like: playing guitar, playing team sports, keeping aquariums, sharpening knives, baking bread, and working on different DIY projects.

TribalScale is a global innovation firm that helps enterprises adapt and thrive in the digital era. We transform teams and processes, build best-in-class digital products, and create disruptive startups. Learn more about us on our website. Connect with us on Twitter, LinkedIn & Facebook!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
TribalScale Inc.

TribalScale Inc.

A digital innovation firm with a mission to right the future.