Konubinix' opinionated web of thoughts

How to Write Good Code Reviews

Fleeting

Best Practices for Code Review | Learn Code Review

[2021-01-06 Wed 07:04]

Review fewer than 400 lines of code at a time

The Standard of Code Review

[2021-01-06 Wed 07:21]

he primary purpose of code review is to make sure that the overall code health of Google’s code base is improving over time. All of the tools and processes of code review are designed to this end.

[2021-01-06 Wed 07:21]

reviewer makes it very difficult for any change to go in, then developers are disincentivized to make improvements in the future

[2021-01-06 Wed 07:21]

reviewers should favor approving a CL once it is in a state where it definitely improves the overall code health of the system being worked on, even if the CL isn’t perfect

[2021-01-06 Wed 07:28]

no such thing as “perfect” code—there is only better code

[2021-01-06 Wed 07:28]

Instead of seeking perfection, what a reviewer should seek is continuous improvement

[2021-01-06 Wed 07:28]

Reviewers should always feel free to leave comments expressing that something could be better

[2021-01-06 Wed 07:30]

be weighed on those principles, not simply by personal opinion

[2021-01-06 Wed 07:30]

. If the author can demonstrate (either through data or based on solid engineering principles) that several approaches are equally valid, then the reviewer should accept the preference of the autho

[2021-01-06 Wed 07:31]

If no other rule applies, then the reviewer may ask the author to be consistent with what is in the current codebase, as long as that doesn’t worsen the overall code health of the system.

[2021-01-06 Wed 07:32]

When coming to consensus becomes especially difficult, it can help to have a face-to-face meeting or a video conference between the reviewer and the author, instead of just trying to resolve the conflict through code review comments

[2021-01-06 Wed 07:32]

Don’t let a CL sit around because the author and the reviewer can’t come to an agreement.

What to look for in a code review

[2021-01-06 Wed 07:34]

For changes like that, you can have the developer give you a demo of the functionality if it’s too inconvenient to patch in the CL and try it yourself.

[2021-01-06 Wed 07:35]

“Too complex” usually means “can’t be understood quickly by code readers.” It can also mean “developers are likely to introduce bugs when they try to call or modify this code.”

[2021-01-06 Wed 07:35]

over-engineering, where developers have made the code more generic than it needs to be, or added functionality that isn’t presently needed by the system

[2021-01-06 Wed 07:36]

solve the problem they know needs to be solved now, not the problem that the developer speculates might need to be solved in the future. The future problem should be solved once it arrives and you can see its actual shape and requirements in the physical universe

[2021-01-06 Wed 07:36]

A good name is long enough to fully communicate what the item is or does, without being so long that it becomes hard to read

[2021-01-06 Wed 07:37]

Usually comments are useful when they explain why some code exists, and should not be explaining what some code is doing

[2021-01-06 Wed 07:37]

mostly comments are for information that the code itself can’t possibly contain, like the reasoning behind a decision