News for hackers. Stuff that matters.
Re:Things Everyone Should Do: Code Review by hubb on Wednesday July 06, 2011 @04:55PM (#2735851)
this fellow is advocating code reviews before checking in changed code to revision control. i can appreciate the benefits of that -- less churn and junk in the repository, the commit history for most files will be succinct, and each change-set will contain a single change or fix.

but doesn't that bring some logistical challenges? how does the reviewer look at your diffs and code if your changes haven't yet been committed? or do you commit, but you branch for every bug fix, and then merge when the review is completed? is there another clever way to do this that doesn't involve revision control?

Re:Things Everyone Should Do: Code Review by skermes on Wednesday July 06, 2011 @05:08PM (#2735896)
I'm not sure why it'd be a goal to find a way to do code reviews that doesn't involve version control. We review everything everything before it gets merged into our mainline branch, and the process is pretty much what you described. Every bug/feature gets a branch, and when it's finished whoever's working on it takes a diff and attaches it to the issue in our bug tracker. The reviewers look at the diff (or, if they want more detail, pull the branch in question and look at the commit history with more context) and then pull the author in to discuss it. Every once in a while we consider either some more clever process or some sort of integrated tool to automate more of the process, but we always conclude that what we have works well enough that it's not that big a deal.

If your source control makes branching/merging painful enough that it's going to get in your way to do it on a regular basis you might want something different, but that seems like an argument for better source control rather than a need for clever reviewing strategies.

Re:Things Everyone Should Do: Code Review by aaronblohowiak on Wednesday July 06, 2011 @09:13PM (#2736729)
We pull the branch and have the reviewer run the relevant tests. Doing this was simpler than figuring out how to do fancy stuff with the ci server (which checks the integration branch after merge.).

Having this step requires the reviewer to know which tests are relevant, which ensures that they were written or updated.

Re:Things Everyone Should Do: Code Review by wccrawford on Wednesday July 06, 2011 @05:02PM (#2735876)
Proper branching.

You check it into your branch, share it, code review it, fix it... Then squash the commits if you don't want all the 'mess' in the final repo. Then finally push it into the trunk.

Personally, I've never bothered squashing. The points that you deploy the code are important, but the visual aspect of the history is not so important. On the other hand, if you want to know when and why a change was done, having the FULL history is a lot more important suddenly.

Re:Things Everyone Should Do: Code Review by gte910h on Wednesday July 06, 2011 @05:09PM (#2735898)
Okay, that's more reasonable than "nothing is checked in without a review".
Re:Things Everyone Should Do: Code Review by masterzora on Wednesday July 06, 2011 @05:06PM (#2735887)
> but doesn't that bring some logistical challenges? how does the reviewer look at your diffs and code if your changes haven't yet been committed?

The easiest method is just passing around diffs, though more sophisticated tools exist. Review Board is one I know of off-hand, though my experience with it was not overly great. I've personally just tossed together a decent diff-viewer with a couple different view modes to account for when, say, a quick patch is sufficient vs. when you really need to see the code in context.

But this is only one solution of many. I actually have seen solutions that involve source control systems, but I've always found them to be too hacky even for me.

Re:Things Everyone Should Do: Code Review by somebear on Wednesday July 06, 2011 @11:13PM (#2736977)
At work we have just rolled out Gerrit as the review tool. The setup is simply that you push your commits to Gerrit, then reviewers can comment on and approve (or not) the change in the web tool. Reviewers can also fetch your patch and run it on their own system.

After a change has been approved, it is pushed into the CI system by Gerrit, and if/when it passes that it is pushed into the public repos.

Before that all reviews were done by passing around diff files.

Re:Things Everyone Should Do: Code Review by neves on Thursday July 07, 2011 @12:41AM (#2737176)
Re:Things Everyone Should Do: Code Review by somebear on Thursday July 07, 2011 @03:20AM (#2737588)
There was a long discussion [1], and in the end Gerrit was chosen. I have used Review Board previously, but actually like Gerrit quite a lot now that I'm forced to work with it ;)

[1] http://lists.qt-labs.org/public/opengov/2011-February/000260...

Re:Things Everyone Should Do: Code Review by Locke1689 on Wednesday July 06, 2011 @05:17PM (#2735934)
Unfortunately, coming from Google he had some very neat tools to help do this that (as far as I know) don't have equivalent counterparts outside Google. It would be harder to do, but distributed version control could help considerably. One possibility would be to make everyone commit to their own local repos and then force a pull request every time they want to commit something to the main repo.
Re:Things Everyone Should Do: Code Review by tghw on Wednesday July 06, 2011 @06:15PM (#2736193)
This is how Kiln[1] got started at Fog Creek. We wanted a good way to do code reviews after checking it in to a branch. (Checking in before you review makes it possible to review the changes in steps, instead of looking at one huge diff.) Django Dash was coming up, so we entered and made that our 48-hour project. By the end of the weekend we had a basic prototype that took two Mercurial repos (branch-by-clone) and calculated the diffs from that.

Fast forward a couple of months, Joel was talking about adding SVN to FogBugz. We were sick of SVN and had this prototype, so we polished it up, presented it, and got approval to start working on it for real.

[1] http://www.fogcreek.com/kiln/

Re:Things Everyone Should Do: Code Review by owyn on Thursday July 07, 2011 @02:35AM (#2737482)
I'm an advocate for code review at the current place...

We already use fogbugz, and I'm pushing for us to switch to hg from svn so that we can use kiln too. Code review is one of the main features that I'm using as a lever. I fear that status quo / apathy may prevail though, since there is a contingent that wants to use git and if it's not unanimous, we stay where we are. Sigh.

Btw, our current process is a skype channel that we use to post links to commits (we use trac at the moment). It actually works pretty well.

Re:Things Everyone Should Do: Code Review by btilly on Wednesday July 06, 2011 @05:56PM (#2736109)
The key tool does have an equivalent counterpart, written by the same people who wrote Google's tool. See http://code.google.com/p/rietveld/ for more.
Re:Things Everyone Should Do: Code Review by Locke1689 on Wednesday July 06, 2011 @06:07PM (#2736155)
Perfect, I thought I was going to have to give up Mondrian if I left.
Re:Things Everyone Should Do: Code Review by btilly on Wednesday July 06, 2011 @06:37PM (#2736275)
Oh, you likely still will have to give it up. You can tell people how well the system works, but the idea of having code review on every checkin sounds like such a heavy process that you'll never convince anyone else to do it.
Re:Things Everyone Should Do: Code Review by Locke1689 on Thursday July 07, 2011 @11:53AM (#2738954)
Guess ill have to take some Googlers with me ;)
Re:Things Everyone Should Do: Code Review by mdwrigh2 on Wednesday July 06, 2011 @08:13PM (#2736565)
Gerrit is open source and is what's used on the Android team: http://code.google.com/p/gerrit/
Re:Things Everyone Should Do: Code Review by jleader on Wednesday July 06, 2011 @05:56PM (#2736108)
When I wanted to submit some patches to one of the Protocol Buffers projects, I was asked to submit them via Guido Van Rossum's Rietveld tool, which is a public re-implementation of an internal Google code-review tool: http://codereview.appspot.com/
Re:Things Everyone Should Do: Code Review by Confusion on Thursday July 07, 2011 @02:26AM (#2737456)
We do code reviews after the code hits the repository. Jira's Crucible tool is awesome for that (it is basically an extension of Fisheye, which is great in its own right). I could imagine Google managing code reviews with something like Crucible just fine, though I may underestimate the consequences of the organisational consequences of sheer size.

Everyone is responsible for making sure the code that hits the repo is up to scratch. Sure this means more bugs hit the repo, but reviews are not primarily about catching bugs: they are about code quality. There's always room for improvement that only other eyes catch, even when there aren't any bugs. The goal is to be bugless without code reviews and people shouldn't start trusting upon code reviews to catch their bugs.

Re:Things Everyone Should Do: Code Review by bulletsvshumans on Wednesday July 06, 2011 @05:48PM (#2736056)
We do code reviews in person, at the reviewee's workstation. It does take time, but we've found that it leads to lots of productive discussion that might not otherwise occur, and that it helps strengthen relationships between team members.
Re:Things Everyone Should Do: Code Review by rimantas on Wednesday July 06, 2011 @05:13PM (#2735920)
That's a part of the beauty of GitHub: pull requests.
Re:Things Everyone Should Do: Code Review by mkjones on Thursday July 07, 2011 @06:40AM (#2737973)
There are tools like Phabricator (http://phabricator.org/) that extract your diff and store it in a database, providing a web frontend that allows others to add inline comments and suggestions independent from the underlying revision control system. We use a version of this at Facebook for required pre-commit review, and I've found it to be quite nice.

Check out e.g. https://secure.phabricator.com/D583 for an example of a diff for phabricator itself that has some inline comments and other input.

Re:Things Everyone Should Do: Code Review by brown9-2 on Wednesday July 06, 2011 @06:40PM (#2736289)
how does the reviewer look at your diffs and code if your changes haven't yet been committed?

Where I work we have a pretty simple script which diffs each file in the Perforce changelist against your local copy and sends it in an email to the team, with some pretty formatting for added/removed/changed lines.

Discussion then takes place over email, which for 99% of changes is good enough since the teams are small.

Re:Things Everyone Should Do: Code Review by RandallBrown on Wednesday July 06, 2011 @06:28PM (#2736238)
Where I work we invite the person over to our computer and they do the review right there. Obviously, this doesn't work when someone is working remotely, but Remote Desktop or VNC work just fine for that. For small one file code reviews we'll often send screenshots of the diffs. (We make screen capture software btw)
Re:Things Everyone Should Do: Code Review by moxiemk1 on Wednesday July 06, 2011 @05:02PM (#2735874)
Some tools (Crucible, at the least) allow you to code-review based off of a diff that specifies the version it is applied to.
Re:Things Everyone Should Do: Code Review by DrJ on Wednesday July 06, 2011 @05:17PM (#2735935)
you should be branching for every bugfix, then when you have fixed the bug and the code passes all known tests + the one for the bug, you should merge it back squashing the branch commit history with a single merge (where you add your own comments instead of just using 'merged in blah blah'.
Re:Things Everyone Should Do: Code Review by MrKurtHaeusler on Thursday July 07, 2011 @08:52AM (#2738220)
In person. Why resort to tooling when simple collaboration and communication suffice?