Live data from Hacker News

How to do a code review

google.github.io

51–60 of 376 posts

Re: How to do a code review

#51

Earlier quoted context omitted.

Here I am just wishing my company would even allow me to post the source of a project I've worked on with any license and apparently Google isn't worth praise for hosting all such projects with an Apache license by default and a review process if you'd like to try to keep copyright. https://opensource.google.com/docs/iarc/

If you live in CA, you're good to do it: https://codes.findlaw.com/ca/labor-code/lab-sect-96.html as long as you do it on your time, using your own resources, and do not compete with your workplace. The fact that google (or other employers) do not go out of their way to tell you this is, of course, understandable.

For any large company this effectively means that almost all of your side projects can be construed as falling afoul of this law.

Re: How to do a code review

#52

I love how the first-mentioned "hardest thing in computer science," naming things, is one of the shortest sections: > Did the developer pick good names for everything? 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. They mention several times a "Nit:" or other prefix for nonblocking comments. I wonder if that is purposeful and/or reflects t…

Of course, the hardest problem is not meant to be mitigated by a common and daily behavior like reviewing code.

Re: How to do a code review

#53
I'd add two things, from a decade of experience at Google:

Review code in this order: protocol buffers, unit tests, headers, implementation. It's common for a new employee to be an expert on C++ or Java or whatever languages but it's very uncommon to meet anyone who knows how to define a decent protocol message. The tests should give the reviewer a very clear idea of what's happening in the code (and this should be congruent with the description of the change), if not send back to author at this point. The headers should contain clear interfaces, types, and comments and should not contain anything that's not part of the API (when this is technically possible). Finally look in the CC file; at this point the reviewer should see things they were already expecting and no funny business.

Any claims about speed, efficiency, or performance whether in comments or during the review must have accompanying microbenchmarks or they should be deleted. Wrong ideas about software performance abound, and even correct beliefs become incorrect with time, in which case the microbenchmarks are critical to evaluating the continued value of the code.

When sending a changelist for review, always clear all automated warnings or errors before wasting the reviewers' time. Nobody wants to see code that doesn't build, breaks a bunch of tests, doesn't lint, etc.

Re: How to do a code review

#56
What's really amazing about this whole thing is that it's more a guide as to not give bad (nit-pickey, overly critical, discouraging) code reviews, than how to give good ones. I think that alone should give us an idea about the state of code reviews in our current industry as a whole.

Re: How to do a code review

#57

I love how the first-mentioned "hardest thing in computer science," naming things, is one of the shortest sections: > Did the developer pick good names for everything? 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. They mention several times a "Nit:" or other prefix for nonblocking comments. I wonder if that is purposeful and/or reflects t…

"Nit" is a Google convention for comments that don't block an overall approval. In other words, you can fix the nits and submit without needing another round of review.

Re: How to do a code review

#58
I feel like the term "open source" is overused. For code, which is where the term came from in the first place, it's relatively easy to define; but what is "source" for something non-code? Is Google really wanting you to contribute to changing its internal processes? I'd say ..."are now public" makes more sense for releasing this document.

Re: How to do a code review

#59
Am I the only software engineer in the world who hates diff-based code review?

Imagine trying to evaluate the quality of a novel by examining diffs to the manuscript. Reviewing every diff means that every single change needs to yield a good novel. But that's an absurd constraint on the creative process - what if you want to introduce a new important character? You check in a new version of the first chapter where the character figures prominently, but the reviewer complains that the new character's plot arc never goes anywhere.

The main goal of this diff-based code review seems to be to prevent people from checking in bad code. But of course you should sometimes check in bad code (especially in the early stages of a project)! You might consciously check in some bad code temporarily, intending to upgrade the code at some future point. More importantly, you generally don't know how or if you're actually going to end up using any given piece of code. Spending a lot of time polishing and reviewing code that doesn't eventually go into the project is a classic example of premature optimization (the root of all evil).

Re: How to do a code review

#60
post #16
post #6

As a side note, their github hosts 1600 repos. Just wanted to say thank you, google.

I would wager that a vast majority of them are personal projects. If you work at Google and want to do some open source project on the side, the code is owned by Google and is under Github.com/google. See: https://news.ycombinator.com/item?id=15592968

Not necessarily: here's Chris DiBona explaining how it works.

https://news.ycombinator.com/item?id=15594045

Post reply on HN