Hi, Habr! In our work we use pair programming and today we want to share with the community tips that help us improve the effectiveness of this method.

When paired programming, two programmers solve the problem jointly, sitting shoulder to shoulder to each other at the same computer. The first acts as a “driver” who prints the code on the keyboard, and the second serves as a “navigator” - he ensures that there are no errors in the program, deals with the code architecture, plans the sequence of actions and thinks about the correctness of coding on a strategic scale. This way of development allows you to maintain a higher concentration, stimulates a carefully thought out solution before it is implemented, and significantly reduces the number of errors and improves the quality of the code.
Why do we use pair programming in our work?
Pair programming has a number of advantages:
')
- Compared to single programming, it allows programmers to more successfully resist stress. Members of the couple encourage each other to maintain high quality code even in tense conditions, when there may be a desire to write dirty code to speed up the task.
- Pair programming improves the quality of the code due to the fact that the observer constantly checks, monitors the quality and clarity of the code and asks clarifying questions. Thus, the readability and clarity of the code of all developers is increased to the code level of the best programmer of the group.
- Pair programming speeds up system development. As a rule, couples write code faster, and most of the errors can be detected immediately in the coding process, rather than testing. Accordingly, at the end of the project, the group has to spend much less time to correct defects.
- Pair programming enhances teamwork. While working on the project, it is recommended that the couple be mixed so that each developer in the team by the time the project ends has a deep knowledge of each of its parts.
- Pair programming provides all the other common benefits of collaborative design, such as spreading corporate culture, training novice programmers, and facilitating joint ownership of work results.
How to make pair programming more successful
To get even more benefit from pair programming benefits, you need to follow a few simple rules:
â„–1. Support pair programming with coding standards
Pair programming loses effectiveness if members of a couple spend time arguing about coding style. To avoid disagreements, it is necessary to standardize the “non-essential attributes” of programming, so that developers can focus on the “essential” task before them and not be distracted by the matching of styles.
â„–2. Do not turn pair programming into observation.
Pair programming is a collaboration, and not the observation of one developer after another. A programmer who does not directly write code should take an active part in development: analyze the code, plan the next step, evaluate the overall program design, think about how to conduct testing, etc.
Number 3. Identify tasks that are advisable to solve in pairs
In most companies that use pair programming, they eventually conclude that in pairs it is better to perform not all but only some parts of the work. With the implementation of simple code fragments, the developer will cope more effectively independently. In addition, in some cases it is more profitable to devote 15 minutes to detailed design on the board and then program one by one to write the most complex code.
â„–4. Change pairs and tasks assigned to them
As with other collaborative development techniques, one of the main advantages of pair programming is that each developer learns different parts of the system. Regular changes in the composition of couples help stimulate the exchange of experience and knowledge among all team members. Some experts recommend changing steam daily.
â„–5. Try to combine in a couple of people with the same pace of work.
When one of the partners works too fast, the second one has to try to keep up with its pace, which reduces the quality of code analysis. In this case, pair programming does not perform the desired function and begins to lose meaning. A member of the pair with a higher speed should reduce the pace, or the pair should be broken up and reformed in a different composition.
â„–6. Both members of the pair should see the screen well.
Make sure that both developers understand the code well on the screen. Improper placement of the monitor or too small a font can reduce the effectiveness of pair programming.
Do not forget about ergonomics - when transferring the keyboard from one member of the pair to another, it remains in the center of the table and everyone has to bend over, both will quickly get tired and start to lose concentration.
â„–7. Do not unite in a couple of people who do not like each other
As in other joint tasks, the better the relations between the members of a couple and the more they correspond to each other in character, the higher the performance will be. The effectiveness of pair programming depends on how well the developers get along with each other, so it’s pointless to unite people who don’t have a good relationship.
â„–8. Do not make a pair of people who previously had no experience in pair programming
The maximum benefit from pair programming can be obtained if at least one of the developers in a pair has already had experience in pair programming and can teach the second one.
â„–9. Choose a group leader
When all team members want to perform implement all tasks using programming in pairs, select a person responsible for distributing the task and monitoring the results of the project.
Do you use pair programming? Share your secrets in the comments!