How Google performs code review | it review in an external publication-Google Chrome

Source: Internet
Author: User
How Google performs code review ?????

Author Mark CC

As mentioned in the previous article, I no longer work in Google. I have not figured out where to go-there are two or three very good job opportunities in front of me. Because during this decision period, I was no longer employed by anyone. I wanted to write something professional, something interesting, however, it also causes tension between colleagues and management work.

Google is a very good company. They have made a lot of commendable things-both outside the company, what people can see, and inside the company. There are some matters that are not kept confidential within the company and are not widely discussed outside the company. This is what I want to talk about today.

The most important thing that makes Google's programs so good looks very simple: code review. Not just Google does this-code review has been widely recognized as a very good practice, and many people are doing this. However, I have not seen that the second such large company can use such things so widely. On Google,No programProgram code of any product or project can be submitted to the code library without any effective code review.

AllCode review is required. And very formal: This kind of thing should be a basic system in any important software development work. It does not mean the Product Program-everything. It does not need a lot of work, but its effect is huge.

What can be obtained from code review?

Obviously: Check the Code with the eyes of the second group before submitting the code to prevent the bug from being mixed in. This is the most common understanding of the benefits of code review. However, in my experience, the opposite is true.Least important. People did find bugs in code reviews. However, the vast majority of the bugs that can be found in code reviews are obviously trivial bugs, and the author of the program can discover them in a few minutes. Bugs that really need time to discover are not found in code review.

The biggest function of code review is purely social. If you are programming, andYesA colleague will check your code, and your programming attitude will be completely different. The code you write will be more neat, with better comments and better program structure-because youYesThe person you care about will view your program. Without code review, you know that people will eventually look at your program. But this kind of thing doesn't happen immediately. It won't bring you the same sense of urgency, it won't give you the feeling of being judged by the same individual.

There is also a very important benefit. Code review capabilitySpread knowledge. In many development teams, each person is often responsible for a core module, and each person only pays attention to his own module. Unless the module of a colleague affects their programs, they never communicate with each other. The consequence of this situation is that only one person in each module is familiar with the code. If this person is on vacation or -- hopefully not -- resign, others will be helpless. Through code review, at least two people will be familiar with these procedures-the author and the reviewer. The examiner does not know the program as well as the program author-but he is very familiar with the design and architecture of the program, which is extremely important.

Of course, nothing can be done simply. In my experience, it takes time to exercise and learn before you can properly review the code. I found that people often make some mistakes during code review, causing a lot of trouble-especially in some inexperienced reviewers, they gave people a very bad experience of code review and became an obstacle for people to accept the code review system.

The most important principle is that the purpose of code review is to find the problem before code submission-you need to find itCorrect. The most common mistake in code review-the mistake that almost every newbie will make-is that reviewers judge others' code based on their programming habits.

For a problem, we can usually find more than a dozen solutions. For a solution, we can have millions of encoding solutions to implement it. As a reviewer, your task is not to ensure that the code to be reviewed adopts your encoding style-because it cannot be the same as what you wrote. As a reviewer of a piece of code, the task is to ensure that the code written by the author is correct. Once this principle is broken, you will eventually suffer from setbacks-this is not what we want.

The problem is that such errors are so common and easy to make. If you are a programmer, when you encounter a problem, you can think of a solution-you can take the solution you think of as a standard answer. But this is not the case-as a good reviewer, you need to understand this truth.

The second easy-to-do problem with code review is that people feel stressed and have to say something. You know the author has spent a lot of time and energy implementing these programs-shouldn't you say something?

No, you don't need it.

It's not suitable to say "Wow, good" at any time. If you always try to find something to criticize, the result will only damage your prestige. When you try to find out something, just to say something, the person under review will know that you just want to fill the silence. Your comments will not be taken seriously.

The third is speed. You cannot rush to a code review-but you must be able to do it quickly. Your companions are waiting for you. If you and your colleagues don't want to spend too much time reviewing the Code and you finish it quickly, the examiner will feel frustrated. This kind of code review will only bring disappointment. It seems to disturb everyone and let everyone put down their work for review. This is not the case. You don't need to let anything off your hand for code review. But if it takes a few hours to complete, you have to take a break, have a cup of tea, take a bath, or have some time to talk. When you return to the review site, you can proceed and finish the process. If this is the case, no one will wait for you.

From Weizhi note (wiz)

How Google performs code review | it review in an external publication-Google Chrome

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.