Bold Idea

View Original

Pair Programming Creates Better Code

By Jeff Grogan

When you picture a computer programmer, chances are he or she is hunched over a keyboard in a dark room, chugging energy drinks with one hand and typing furiously with the other. Much more often, though, programmers work in pairs and in clean, well-lit offices.

Programming pairs are made of a "driver" and a "navigator." The driver types code into the computer while the navigator catches typos and suggests additions or changes. Programmers switch roles frequently during a project, which fosters their deep knowledge of the program and allows each partner to practice both skills.

Why not work alone?

Some software engineers still hold onto the superhero (or villain) mantra, "I work alone." To be sure, pair programming has serious trade-offs to consider, but research makes clear this technique has real benefits in many situations.

Someone's watching you

Partners place valuable pair-pressure on one another, since each wants to impress the other with his or her coding and proofreading skills. This pressure helps keep both programmers focused, reducing time following wild goose chases during troubleshooting.

Pair programmers also gain opportunities to teach their partners, which either solidifies their knowledge or corrects their mistakes. Studies also show young programmers who work in pairs show increased persistence when facing a problem. All these factors help equip students with the confidence and skills to take on challenging tasks alongside a constant, supportive peer.

Worth the cost

Common sense would tell employers that hiring two programmers to work on a single project means spending twice as much money as necessary. However, results from a University of Utah experiment reveal otherwise: "Because the pairs worked in tandem, they were able to complete their assignments 40–50% more quickly."

In addition, pairs have been found to produce code with much fewer mistakes than individually written code. The cost of finding and fixing errors makes pair programming at least as efficient — and certainly less of a hassle — than working alone.

More fun with a friend

Pair programming is not only a worthwhile investment, it also helps coders to enjoy their job! The same study at the University of Utah found 96% of professional pair programmers enjoyed their pair-programming tasks more than when they programmed alone.

Young programmers also overwhelmingly enjoy working in pairs. One researcher in the UK found that successful programming partnerships increased middle school students' favorability toward computer science and likelihood of continuing to study the subject.

Immeasurable results

Simply talking to children engaged with computer science can tell you what any number of scientific surveys have struggled to document: Kids who have fun learning at a young age are much more likely to become lifelong learners. Pair programming helps even the most introverted young people express themselves and invent new ideas with their partners and friends.

Jeff Grogan is a professional freelance writer and editor. He supports Bold Idea because he believes in the unifying, empowering effect programming can have on students. Bold Idea inspires him to work graciously and meet practical needs with the skills he has.