Abstract: pair programming (Pair programming) comes from extreme programming XP (eXtreme Programming), is one of its twelve best practices. As the name suggests, pair programming is where two programmers sit together and develop code in pairs.
This article is shared from the HUAWEI cloud community " pair programming is good or not ", author: Senior Sister Mei, agile Jianghu Taohuadao.
What is pair programming
Pair programming comes from extreme programming XP (eXtreme Programming) and is one of its twelve best practices. As the name suggests, pair programming is where two programmers sit together and develop code in pairs. In Extreme Programming, all software products are completed by two programmers sitting side by side on the same machine.
Figure 1 Pair programming
Two forms of pair programming
When adopting pair programming practices, different teams have different forms. Some have a clear division of labor, one person is responsible for writing the code, another person is responsible for reviewing the code, responsible for the correctness and readability of the code; another person is responsible for detailed design, one person is responsible for code implementation; or one person writes functional code and one person writes tests Example. Some are cooperative types, in which two people discuss the architecture design, coding implementation, testing method, code style, etc. of the developed function, and then take turns to do the work of input and observation.
"Old with new" does not belong to pair programming
In China, there is another way of pairing everyone is "old to bring new", an old employee brings a new person, this is actually not a strict sense of pair programming, it can be regarded as a form of training new people. In this way, the pairing will have a word-for-word phenomenon and lose the meaning of the pairing itself.
The current state of pair programming
There are many voices about pair programming on the Internet. Compared with other agile practices, it is almost the most controversial. According to VersionOne’s 14th Annual State of Agile Report, in the agile engineering practices adopted by organizations, pair programming accounts for 31% of the surveyed companies, ranking eighth, second only to continuous deployment, and higher than TDD. This shows that pair programming There is still a place and a good point.
Figure 2 VersionOne's 14th Annual Agile State Report-Agile Engineering Practices Adopted by the Organization
Regarding whether an organization should adopt the practice of pair programming, it is mainly whether it is suitable for their own projects and conforms to their company's culture. When choosing a certain practice, we must have both form and spirit. If we only arrange two programmers to sit together, one writing and the other watching, this is only a formal conformity, and the key is to understand the concept behind this practice. . In pairing, two programmers are usually required to be of similar level, so that they can complement each other and cause discussion. The wisdom of two people is greater than the wisdom of one. This is the basic basis for pair programming, which will improve product quality and work efficiency. Let's take a look at the characteristics of pair programming together.
Features of pair programming
From the project point of view, the product quality has been improved
When pair programming, two people work together to complete a function, which can avoid personal misunderstandings. Usually, personal ideas are inevitably limited. When you look at the code you wrote, you always feel that everything is right. Everyone can see each other's errors from different angles. In addition, through pairing, the code is reviewed by at least one programmer, which makes the design, testing, and coding more friendly, reduces defects, and improves product quality.
In addition, the form of pairing also ensures that at least two people in a function know about each other and form a backup, and there will be no situation where one person asks for leave or resigns, and no one knows the follow-up. Some companies also regularly change pairs of people, so that team members can be familiar with the various functional modules of the project, forming an atmosphere of collective ownership and responsibility of the project, and avoiding the phenomenon of one-person responsibility system and self-sweeping. It also allows team members to quickly become familiar with the business.
From the perspective of the team, better realization of knowledge transfer and sharing, making the relationship between members more harmonious
It is undeniable that this kind of face-to-face communication is the best way to transfer knowledge and skills. At the same time, this kind of instant communication also makes the relationship between colleagues become harmonious, which is more conducive to creating a harmonious team atmosphere than writing code in a grid for each person. According to the theory of "Johari Window (Communication Window)", in the interpersonal communication of actual work, the more common open areas, the more convenient the communication and the less likely to cause misunderstandings. When we expand our public quadrant to others, we will build more good relationships with each other. Pair programming is a very good form.
Figure 3 Johari window
Pair programming is actually in the running-in of the pair, slowly forming a common value and culture of the team. This process is long and subtle. It will inevitably go through the process of disagreement and unity, and many teams stop directly in the disagreement. With practice, the benefits of pairing cannot be seen.
From a personal perspective, it improves personal ability and efficiency
When working in pairs, each person will not only learn new knowledge and skills from each other, but also be affected by the other's work style and attitude towards the world. The ruler is short and the inch is long. Everyone has their own strengths and strengths, and they deserve to be learned and respected. When the ability of everyone in the team improves, it is actually an improvement in the ability of the entire team.
In terms of work efficiency, pair programming allows everyone to focus more on work, and some personal activities outside of work will not be carried out. Everyone has their own tasks. The two people actually form a small team that supervises each other and makes progress together. In order to complete the team's tasks, both of them will focus on their own tasks, which improves the efficiency of output.
Questions about pair programming
As mentioned earlier, there is a great controversy over pair programming, mainly due to the following two points.
Managers believe that labor costs are increased
The work that one person can do becomes two people do, and the output is reduced by half, which is obviously a waste. Regarding the improvement of product quality, it cannot be seen in a short time. Therefore, pair programming is considered a bad practice.
The team found it difficult to find the right pair
Firstly, there are not many people in the team with not much difference in level; secondly, pairing requires two people to have the same temperament and personality, otherwise it is difficult to cooperate; thirdly, some people like to fight alone and are not good at cooperating with others, and so on. And reason.
Regarding the above two points, no judgment is made here. Agile development does not mean that all agile practices have to be implemented in your own team, or the saying: The best for you is the best.
Click to follow, and learn about Huawei Cloud's fresh technology for the first time~
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。