Microsoft is how to make the Code Review

This article by the users know almost diffuse slow busy translated from Dr. Michaela Greiler of How Reviews Work AT in the Microsoft Code , the author's research team how Microsoft is doing code reviews, and do the relevant summary. Original link with a large number of resources, this is not sorted out, you can view the original acquisition related links

Have you ever thought about one of the world's largest software company is how to ensure high-quality code through the code review?

me too. So, I investigated together with colleagues how Microsoft is code review. Their approach is a common practice it? Whether developers need to code review? What tools do they use? Let us find the answer in this article.

First of all, let me provide some key information about Microsoft for you. Microsoft Approximately 140,000 employees. Of which about 44%, or more than 60,000 employees are engineers. Thousands of engineers while using the same code base development and other Office, Visual Studio or several Windows products.

Imagine, ensure that the code developed by different teams work together perfectly can the child be a daunting task. In Microsoft, the code review plays an important role in ensuring smooth coordination can be achieved in such a large range.

Microsoft code review is an integral part of the development process

At Microsoft, engineering practice code review is a widely used. The vast majority of engineers think this is a good best practice. And most high-performance team have spent a lot of time code reviews.

A survey of Microsoft code reviews

Because the code review plays such an important role in the Microsoft development process, so it is our in-depth research and really understand the pros and cons of this approach over the target. In large-scale studies on the review of the code of conduct Microsoft, we interview, observation and investigation of the practice of code review of more than 900 developers.

Our aim is to understand how Microsoft accurate code review. We want to know what pitfalls code review, code review and best practices they developed to overcome these challenges developers will encounter during code review.

What can you to review the code from Microsoft's practice of high school?

Most of the lessons are very valuable, whether for small teams and organizations, or for large groups and organizations. If your team has not performed code review, we will demonstrate the benefits of our discovery and code review to you. I will also explain the life cycle of code review, so that you can practice this into their development process.

If your team has implemented a code review, you can practice your code review practice and Microsoft were compared. Your code review life cycle looks any different? In the next article, we will introduce code reviews and code reviews trap best practice. With this information, you can begin to see if your team has implemented all the best practices and introduced me to overcome challenges. Now let's get started.

Microsoft engineers How often do a code review?

In this study, 36% of developers said they repeatedly execute code review day. Another 39% of developers said they code review at least once a day. 12% of people several times a week review of the code, only 13% said they did not conduct code reviews in the past week.

This means that Microsoft's developers will spend a lot of time on code review. Therefore, it is important to ensure that this time spent is worth it. So, code review What are the benefits?

Code Review What are the benefits?

Developers mentioned, the biggest benefit is to improve code quality code review and found defects in the code. Another important benefit of code reviews is knowledge transfer.

Knowledge transfer means checking each other team members code will be familiar with most of the code base. This also means that the code review best practice within the team is growing formation. Another advantage is that the new team members and junior developers can view or obtain feedback at the same time to learn and improve their coding skills.

If the developers to discuss alternative solutions during a code review, it will not only improve the code base, but also for all those involved have a role in learning. Therefore, learning, guidance and self-improvement is seen as beneficial to Microsoft code review practices reasons.

Developers usually do code reviews?

Code reviews can be carried out in various ways. Can a developer go look at some code that another developer with a desk, you can also check the code with the team. However, when Microsoft code review, the situation is most likely to encounter is the code review is done using tools.

Microsoft code review is usually done through an internal tool

There are a variety of code review tools available, and Microsoft, teams are free to choose their tools. In 2016, 89% of developers say is to use CodeFlow code review tool. Later, I will explain more about this code inspection tool. Since then, with the rise of Git, use of tools has also changed. Let's consider a typical review:

Let us imagine a developer of Microsoft, for the time being let's call her Rose. Rose has just completed a part of the function, and now want to get feedback colleagues.

How Rose code review in Microsoft?

Well, Rose ready to get some feedback. So, first of all she is ready to review the code. This step includes her open to change the code checking tool, a preview of the code. Code review tool to perform some comparison tasks, help Rose can see exactly what changes she made.

After careful examination of these changes, she prepared some explanation, tell reviewers what she had done and why. This description can help reviewers understand the purpose and motivation code changes. Now, you can send the code to the reviewers.

How Rose select the appropriate code reviewer?

Many experienced developer knows who should participate in code reviews. However, the team's new members or new areas of work, chose them can be tricky. If Rose does not know who should be added, she can view the policy team or ask a colleague. She can also use the code review tool recommendation feature that can help her to choose reviewers.

Who are the relevant reviewer?

Rose chose to believe she can contribute reviewers knowledge of the code. Reviewers usually other developers, but it may also include other stakeholders, such as dev-ops engineer, UI or management personnel. Reviewers may be selected because of their expertise, it may be that they need to keep abreast of upcoming changes.

Rose requirements Reviewers provide feedback

Once selected the reviewer, Rose will send a code review request. Code review tool will automatically send notifications to notify reviewers have created a new code review. Notification will be sent to all reviewers. Generally, however, the team manager or product manager will be added to the notification list, and automatically notifies them for each review. These notifications enable them to understand the relevant information, but they do not need to perform the audit.

Receiving feedback is an iterative process

Once Rose colleagues have time, they will look at the code review. Each reviewer can add notes and comments in the code. After completing the review, the reviewer will be annotated code is sent back to Rose. Rose can now handle these comments and prepare a new version of the code.

Reviewers often view some of the information: Is there a code look wrong? There are problems on the architecture it? Are there some minor problems, such as lack of explanation, spelling errors? Not all comments are equally valuable. However, there are several best practices to enhance the value of code review comments.

Rose prepared a new version of the code

Rose through amendments and settlement proposals to deal with feedback. If Rose found some misunderstanding or other controversial issues, she might find colleagues discuss in person. This is sometimes easier than through the tool and more personalized.

In any case, once she finished with all of the feedback, the new version of the code will be sent to reviewers. The new and improved version is called revision.

If needed, she will receive further feedback. Whether this iteration continued several times depending on the type of change and quality. For simple and small code changes, usually only one code review changes. For other more complex or change the code in question changes may require several iterations.

This is perfectly normal, in part because the code review feedback cycle to stimulate discussion between the author and the code reviewers.

All reviewers are approved, Rose code check

After this review period, we will review the code marked as OK, then Rose code can be checked in a common code base.

Some teams developed a number of policies that allow developers to complete the review before the actual check-in code. This is usually for some minor changes, to allow asynchronous review and speed up development.

All the steps I have described are part of Microsoft code review typical life cycle by all teams perform. According to team policy, the requirements of each step of the team will be more stringent.

Not all teams are the same

You can imagine, Microsoft has 60,000 engineers and a lot of teams, not all operate according to uniform standards. Microsoft's team might need some additional steps or code inspection tool in the life cycle. I want to outline some of the team to add some extra steps in the code review process.

Code review contains the test results

You want the most features may be through the "automatic detection" error code to save time. I mean, if you can run automated tests and realized that the code does not work as expected, this is what you should do: run the test before the review.

This is the reason why some teams are to submit test results at each code review requirements. So no one would forget to run unit tests. And it can ensure that the test has actually run by a given code changes under.

Other team even further, in some way to configure the code review tool: developers to submit each code review will trigger a build. This version contains the exact change, and also launched a series of automated tests. The results of these tests will be constructed and attached to the code review. Configured this way, you can ensure that the latest code using a common code library code changes were tested.

It contains the user interface code review

If the change affects the user interface, it requires developers to submit a screenshot also a good idea. In this way, the code reviewers can see the impact of code changes without running the code. Secondly, on your computer when you run the code, code reviewers can find differences.

Static analysis includes code review

Static analysis tools in terms of coding style questions, you can save a lot of time codes reviewers. Microsoft will automate some team static and dynamic analysis tools as a dedicated robotic reviewers. These robots give comments on the code style and other static problems. Therefore, it can free up time for manual code review to execute more interesting tasks.

Microsoft code review tool

One of the criteria over the years, Microsoft code review is in fact an internal tool CodeFlow. This is a complex code review tool that enables developers and guide them through all the steps of the code review. CodeFlow assist in the preparation of the code, automatically notify reviewers, and has a wealth of comments and discussion features.

You can see in the following screenshots, CodeFlow is a heavy UI tool, very similar to Word or PowerPoint.

CodeFlow Interface Description

If necessary, you can skip this step if you are interested, I will walk you through CodeFlow interface. View screenshots on the left (A), you'll see all the affected document.

Also on the left, you'll see (B) assigned to the present review of the list of reviewer and their status (for example, has been signed or pending). Active document is displayed in the editor (C) in. At the bottom, you can see a list of comments (D) of all documents.

On the other hand, in the active document (F) only one comment. This particular section of code with the annotation (i.e. a word line) is relevant. Finally, at the top, you will see the overall status code review, and completion status is in the screenshot. Before the digital representation of different revisions. In this review, there are five amendments.

Annotations

CodeFlow one of the best features is its annotations.

Code review can very accurately choose her want to comment part of the code. For example, the reviewer can even highlight only one row or two characters, rather than highlight the entire line. Then, the reviewer can select additional comment.

The comments will be sent to the author of the code or other reviewers, and can initiate a conversation about the comment.

Comments

This feels like Comments comment on issues such as Twitter or Facebook like social media platforms. Therefore, CodeFlow comments in a very natural experience can be a rich dialogue and discussion. Another nice benefit is that you can assign a status of each comment thread. The status can be "unsolvable", "resolved" or "unresolved."

Comparison between the revised code review

A useful feature is the ability to select two different versions of code review and compare the differences between the two. This means you can see exactly what the code of conduct a code review changes between revisions and revisions another code review. Audit tracking progress very easy.

Code Review Analysis Tool

At Microsoft, developers spend a lot of time to code review. To ensure that these valuable time spent, Microsoft has its own code review analysis platform.

The platform stores all code inspection data, starting with the code being checked, the developer code checks involved, then all comments developers. Even in the days of code changes for each revision.

These data are Microsoft code review for code review some empirical research foundation. Many product teams also use it to track their productivity and understand their own code review practices. In addition, I am sharing this blog post series in a number of insights into Microsoft code review of all the research and analysis of the data from the code review.

Micorsoft future code reviews

With Micorsoft participation and acquisition GitHub, some changes are inevitable. For example, Microsoft has been widely adopted as the Git source code version management tools. Meanwhile, Microsoft, code review carried out in the form of pull requests are increasing.

Guess you like

Origin juejin.im/post/5db7c542518825644e28b423