📜 ⬆️ ⬇️

One head is good, but two is better, or pair programming in action


Driver and Navigator in action (North Korean version of the methodology)

From the translator: today we are publishing an article for you by Andrew Spruhl , a Data Science specialist. He talks about the advantages of the pair work of programmers on the same project.

I often hear people say that they work best alone. I understand that some ideas and methods that are suitable for one person are not suitable for another. But still the saying “One head is good, and two is better” is close to me. Under the cut are two videos that show how well two people can work on the same task. It is just harmony - both literally and figuratively.

Skillbox recommends: a two-year hands-on course “I am a web developer PRO” .

We remind: for all readers of "Habr" - a discount of 10,000 rubles when recording for any Skillbox course on the promotional code "Habr".



Here is the second video (the author has banned embedding on third-party resources, but you should definitely look at it).

Music is not the only area where the cooperation of two people can benefit the overall project. There are much more of them, as described by Michael P. Farrell, a professor of sociology at the University of Buffalo, in his book Collaborative Circles: Friendship Dynamics and Creative Work. In particular, he believes that many great ideas came from people who worked in pairs: it could be scientists, artists, writers.

In painting it is Monet and Renoir, in writing - Tolkien and Lewis, in science - Creek and Watson ... You can list for a long time. Moreover, about half of the Nobel laureates in the category “Physiology and Medicine” are teams of two people.

Well, in our time, excellent results are given by “pair programming”, which Wikipedia describes as an agile method of software development, which consists of the work of two programmers at one workstation. One of them, the driver, writes the code, the second, the observer, monitors the process and reads each typed line. Programmers often change roles.

This technique is not related to the work on the model of "teacher-student", it is a question of the joint work of two equal specialists. One of them may have more experience, but they work in the same way, the rights are equal. In general, the idea is that two people find a solution faster than one.

Initially, it can be difficult for a couple to work smoothly, and indeed such a workflow will seem ridiculous to many. But here, as elsewhere, experience is needed. Over time, work gets better and the process goes smoothly, with almost no problems.



Again, in pair programming there are two roles: driver and navigator. The main task of the first is to follow the details of the code, to implement ideas, turning them into lines of code. The driver and navigator should discuss ideas and problems.

The navigator pays attention to each typed line, and this attention is not scattered, since it does not need to type text. The main goal of the navigator is to convey clear ideas to the driver. The navigator must give the driver instructions with a certain level of abstraction so that he is able to implement them as efficiently as possible.



If the driver has an idea, then the navigator and the driver can switch roles. This helps partners work synchronously. Sharing ideas is akin to brainstorming, only this is a more efficient process, plus the error rate decreases (as shown in the diagram above).

I can advise specialists who work in pairs to sometimes interrupt and ask each other questions. It helps to think in one direction, understand each other and work efficiently.

Pair Programming and Workflow




Studying the issue of pair programming, I found that there are several strategies for such work. Some of the options can be found here . One of the most interesting strategies is called “Ping-pong sparring”. It works as follows:

Yes, it does not look like an ideal workflow, but we will not know how effective it is until we try.

I recently learned from a classmate that Atom has a Teletype package that allows developers to work together in real time, giving colleagues access to their desktop. This is even better than simply sitting together at the same workstation, because it allows you to be in more comfortable conditions and less distracted.

And do not forget: the roles during the day must be changed. However, you cannot use the timer, as it will interfere with the workflow. Many believe that you should switch roles within the 30 minute interval. But here everything is subjective.

The adaptation period during the transition of singles to pair programming is similar to eating hot pepper. The first time, everything is wrong, you do not like it. But the more often you eat pepper, the sooner you start to like it.

In conclusion,


I once heard the phrase: “In order for an idea to be realized in a figure, it is necessary that it pass through the hands of another person. This type of programming is about communication and collaboration. ” It seems to me that it is communication and cooperation that are two components of successful work.

I myself am more productive when working in a pair with someone. My experience as a musician suggests that playing in an ensemble is better than being a solo artist. This is not because I depend on another person; rather, my confidence in success increases when I see that total work is more efficient. Now I have a better navigator than a driver, but I am gradually improving. Hope this article will help your future projects.

Skillbox recommends:

Source: https://habr.com/ru/post/436442/