1 the introduction

Any software is co-developed, so CodeReview is very important to help you reduce code quality issues, improve development efficiency, and improve stability, while maintaining the stability of your software architecture and preventing code structures from being malevolent and difficult to maintain.

Therefore, CodeReview is one of the determinants of the long-term health of an engineering team. This time we read an article about how CodeReview can be made better.

2 Overview & Intensive reading

The author introduces his own views on how to make CodeReview a good one based on his work experience at Uber and Microsoft.

Coverage of CodeReview

Good CodeReview checks the code for correctness, test coverage, functional changes, compliance with code specifications and best practices, and can point out obvious improvements such as hard-to-read writing, missing variables, boundary issues, large number of commits that need to be split, and so on.

The Better CodeReview examines the need to introduce code, whether it fits with the existing system, whether it is maintainable, and whether the code is consistent with the existing system logic from an abstract perspective.

The Better CodeReview focuses on maintainability and is global, where several locally correct pieces of code together produce incorrect results, unnecessary code, or conflicting logic. Better CodeReview is more often used in the scenario of the underlying architecture, because the modules at the bottom of the architecture are closely related and need to have an overall perspective, while it is Better to adopt the decoupling mode between the upper modules of the business, so that Better CodeReview, which requires more energy, is also a more correct architecture design.

The tone of CodeReview

Good CodeReview will give constructive suggestions, rather than making strong remarks asking for correction or believing that their own opinions are the only correct answer, because such comments are actually aggressive, which will arouse defensive mentality and create hostile mentality of the other party, which will collapse a team from the inside. It’s best to offer advice, or to keep options open.

Better CodeReview is always comprehensive and positive. It encourages good writing and shows considerate care for bad writing. Considering that the other party may have spent a lot of effort, it makes comments with an encouraging attitude of empathy.

In fact, after reading the chapter of tone, I gradually found that CodeReview is not only a technical and professional behavior, but also a social behavior of getting along with people. Some people are very humble when dealing with people, but they become sarcastic in CodeReview. Obviously, they only pay attention to the professional side of CodeReview. Ignoring the social aspect. In order to achieve Better CodeReview, you need to learn to put yourself in others’ shoes and show tolerance and positive attitude. Because you have more technical experience, it is normal to point out others’ problems, but you can be humble and easy to accept and encourage others, so that you can become a dignified technical expert.

How to complete the review of CodeReview

Good CodeReview won’t easily pass open PR, at least until it’s fully discussed, but every reviewer needs to give feedback on the part they care about when they’ve finished reviewing it, whether it’s “looks Good” or using the acronym “LGTM”, and then clear follow-up, For example, collaborative software notifies authors for further feedback.

The Better CodeReview will be more flexible in practice, leaving improvement suggestions for more urgent changes but passing them quickly, allowing the author to resolve remaining issues through subsequent code commits.

Real work scenarios will encounter some open or urgent submissions, and a good CodeReview habit is to be rigorous, discuss before approving, and give feedback in a timely manner. A better attitude is to be flexible in practice, but still make sure the problem is fixed later, such as leaving a “TODO” or “FIXME” mark in the code with the owner and expected resolution time.

From CodeReview to direct communication

Good CodeReview provides complete reviews and suggestions for changes, and if the code submitted later doesn’t meet expectations, the reviewer can talk directly to the code submitter face to face to avoid spending too much time later.

Better CodeReview provides complete comments and suggestions for changes at the first time, and if subsequent submissions do not meet expectations, it immediately communicates with the code submitter in person to avoid further misunderstanding caused by asynchronous communication.

In addition, when the PR content is too much, you can also choose to directly communicate with the submitter in person, so that you can better understand the author’s ideas and make the Review more accurate. Instead of communicating directly every time, the asynchronous CodeReview is an efficient solution that allows you to work at your own pace, and only communicate in person when the solution has communication problems.

Distinguish between the key

The Good CodeReview differentiates the importance of prompts and prefixes less important changes with “Nit:” to keep submitters focused on important issues.

Better CodeReview fixes these problems with tools, such as some code Lint tools, because these problems can often be solved automatically by tools.

A large part of the purpose of code automation tools is also to ensure code consistency, thus reducing CodeReview costs, as well as reducing the incidence of unimportant comment messages, so that CodeReview can respond to logic rather than formatting problems as much as possible.

CodeReview for newcomers

Good CodeReview applies the same criteria to everyone, so follow these tips.

Better CodeReview treats new hires differently, offering more patience, explanations, comments, even solutions, and more positive encouragement.

Everyone has to adjust to a new company. It is base requirement that they are treated equally, but it would be better if they could show more care to new employees.

CodeReview across office areas, time zones

Good CodeReview is conducted only during overlapped working hours to ensure that the other party is responsive to voice and video communication when necessary.

Better CodeReview takes note of the more fundamental issues and the need for cross-team collaboration. If a module is constantly being modified simultaneously in another time zone, it may be more efficient to hand that module over to the other team for maintenance, or to hand CodeReview over to the other team for internal implementation.

My company also has cross-time zone collaboration, but most scenarios avoid cross-time zone CodeReview, because CodeReview is usually conducted within the same time zone team, which is more efficient. When dealing with cross-time zone collaboration, telephone and video conferencing are often preferred.

The company support

Good CodeReview is supported by the organization, which recognizes that while it may seem to take up development time, it improves development efficiency in the long run and therefore provides any CodeReview value.

Better CodeReview will get further support from the company. The company even continuously develops and improves the CodeReview system and process, and ensures that the above CodeReview matters needing attention are implemented within the team through systematic plans and full participation.

CodeReview is also a kind of team culture and company culture. Company culture brings rules and regulations and system tools, while team culture brings good CodeReview atmosphere and higher CodeReview efficiency.

3 summary

To sum up, a good CodeReview needs to do the following:

  1. More comprehensive, from correctness to system impact assessment.
  2. Pay attention to tone, from giving constructive awareness to perspective-taking.
  3. Complete the review in a timely manner, from full discussion to improvisation.
  4. Enhance communication, from face-to-face communication to flexible choice of the most efficient communication methods.
  5. Prioritize, from tagging to automating with engineering tools.
  6. Be nicer to new people.
  7. Avoid collaboration across time zones and use video conferencing when necessary.

Finally, I hope CodeReview can get the support of the company. If your company has not recognized the value of CodeReview, you can share this article with your leader.

How to make a Good CodeReview · Issue #237 · dt-fe/weekly

If you’d like to participate in the discussion, pleaseClick here to, with a new theme every week, released on weekends or Mondays. Front end Intensive Reading – Helps you filter the right content.

Pay attention to the front end of intensive reading wechat public account

Copyright Notice: Freely reproduced – Non-commercial – Non-derivative – Remain signed (Creative Commons 3.0 License)