1
Original: Yuantiandi (WeChat public account ID: cxytiandi), welcome to share, please keep the source for reprinting.

CodeReview I believe that many companies will have such a process at present, the key is that it is difficult to tell whether this process is useful. It mainly depends on your understanding of CR and whether you have really implemented CR and pay attention to the hidden value points brought by CR.

Just recently, someone was asking me about CR-related issues, and they are also starting to do CR, wanting to know if there are any best practices or the like. So today I will talk to you about the topic of CR, what I said may not be all right, just for reference.

In fact, to be honest, I don't think there are any best practices for CR. Because each company or each team has a different approach. If you really want to do CR well, you can only do it first, implement it in the R&D process, and then slowly refine the one that suits your team. CR method.

1. The purpose of CR

Since CR is to be done, there must be a reason. What exactly is the purpose of ? It can be a process, it can be to improve code ability, or it can be everyone is doing it, and I will do it too. I think the purpose is as follows, please look down.

1.1 Stable production

Think about it, every iteration will be tested after the development is completed, and will be released to production after the test is completed. Then the most likely problem is that your new function may have changed to the old logic, and the hypothesis test did not return this problem. Then it affects the stability of production as soon as it goes online, so the most important purpose of CR is to stabilize production.

We need to perform CR on the code to see if there is any change to the old code, will it affect the old logic, whether there is a switch, and whether there is any bottom-up action. Because there will always be new people in a team, if they are not very familiar with the business, they are likely to correct mistakes, and it is likely to leave a hidden bug. These all require CR to focus on.

It is okay to go online, it must not affect the old version, and it must not malfunction, otherwise your performance will be cold. You said that you don't want to do CR. Will your colleagues allow it? The boy should do CR obediently!

1.2 Indirectly cultivate backup

When managing a team, you must pay attention to cultivating backup, because you don't know who will be the next person to leave the team. Internet companies still have a liquidity, 160d6d0848ad3c, because only job-hopping can increase wages, I also told everyone’s mind .

Except on the bright side, you can specify who is the owner of a certain piece of business. When developing, the owner will take other people to develop together. In this process, there is actually a backup, because this piece of business does not know that it is a certain person. Up.

Also pay attention to cultivating backup under the counter. At this time, CR is a good opportunity. In CR, you can make more people familiar with these businesses, but you must pay attention to the way, don't just look at the code, so that those who are not involved in the development must be in a very confused state. Before CR, let everyone take a look at the PRD first, and then let the CR people explain it to Review instead of line by line of code. First, you need to talk about what you need for this iteration and what functions it has. The corresponding code is now CR’s. Code. Only in this way can everyone understand the business and do CR, killing two birds with one stone.

Of course, at this time you will say that even if you perform CR in the way you said, it may not be familiar to others! This is of course, the most familiar is the person who wrote the code! But we gave other people a general impression. If the person who wrote the code later quits, when there is a bug to be fixed, other people will also have an image of where the code of this function was at that time. I still remember CR. I also made some suggestions. Better than not knowing anything, are you right?

1.3 Improve code quality

Starting from a purely technical level, the purpose of CR is to let everyone find faults and pick points. Everyone’s experience is different, and everyone’s thinking is different. Often you think that writing this way is the easiest way, and others may have a simpler way to achieve it.

In the process of CR, everyone will put forward their own views, ideas for implementation, whether the code is written concisely, whether there is an open source framework that can directly implement a certain function, whether it can be optimized with design patterns to improve scalability. Whether the domain modeling is reasonable, whether the module division is in place, and so on are a series of questions.

For the newcomer, it is very helpful for him to grow up to get the advice given by many experienced colleagues in CR. It will also keep the quality of your project code at a high level. This is the purpose of CR. Of course, the reality is often cruel. Many projects will be messy in the end, and the code will be bloated. I think it may be caused by the business side's reordering and rushing to go online at that time! This situation is very common, especially in startup companies.

2. The way of CR

I talked about a few points before. I think the purpose of CR, then how to perform CR? What are the common ways, come, and then look down.

2.1 Gitlab

Before using Gitlab to do CR, you usually make an MR request first, and then do CR for this request. All the changes in this MR request are the points where we need CR. If there is anything that needs to be modified, you can add remarks to the corresponding code. After CR ends, modify them according to the remarks at the time.

2.2 Development tools

It is also very convenient to directly perform CR in our development tools. The advantage is that you can see all the codes of the entire function, that is, you can follow the business process to explain the corresponding code. Then you can clearly compare which are your own changes and which are the old code.

3. Timing of CR

3.1 Before testing

Before the test is the best time to CR, at this time we need to improve and then directly change it after CR. Then when we tested it, it was the code after we changed it, maybe a lot of bugs were reduced, and the test was as smooth as silk.

What is the impact of CR before the test? It’s our development time. It was originally proposed to test immediately after the development is completed, but CR should be performed before the test. Unless your development progress is advanced, how to do CR before the development is completed?

This is actually the process we talked about above. CR is integrated into the R&D process, so that one day's buffer can be reserved for CR during the evaluation time. For example, if the 11th is to be tested, then the 10th is CR, and the 9th That is, the development is complete.

3.2 After the test

Doing CR after the test is actually very bad. We have done this before, and immediately changed it to before the test. Because in the process of doing it, some points that need to be modified will be proposed, and then these points may have been tested. Then you changed it again, resulting in new bugs and increased testing workload.

There was even one time when it was changed on the spot during CR, and then it was submitted directly without paying attention, and it was not synchronized with the test. The next day, the production environment has a bug directly, so be sure not to perform CR before the online test after the test.

To give another example, there was a team who always liked to perform CR on the day of launch. The test has returned as a whole, and they are still in CR. Of course, I don't know if there are any changes to the code, because it is not a team, but the most serious thing is that there are bugs during the regression, which need to be fixed in time. Then they couldn't find anyone to repair, they went to CR, and no one paid attention. The result is that every time it goes online, it is too late.

3.3 After going online

After you go online, you don't need CR. What's the point of CR after you go online? The code has been released. At this time, the problem of CR should be changed or not? Will it be changed in the next iteration? After the next iteration, do you have to come back again? Are you willing to test?

As the saying goes, today’s things are finished today, and the current iteration’s issues will be resolved in the current iteration, otherwise it will be piled up.

to sum up

For CR, we still have to actively embrace, go to the ground, and practice. It looks like it will take some time, but the benefits it brings are still very good. The code quality of the project has improved, the technical atmosphere of the team has improved, the number of online bugs has obviously decreased, and everyone is more familiar with the business.

If you don't have CR, please give this article to your boss, it's that wayward.

is useful to you, let me forward it!

About the author : Yin Jihuan, simple technology enthusiast, "Spring Cloud microservices-full stack technology and case analysis", "Spring Cloud initiator.


猿天地
315 声望215 粉丝