We started requiring code reviews for everything, and my head hasn't exploded
bjk5.com
bjk5.com
Robert Glass suggests that "RI1. Rigorous reviews commonly remove up to 90 percent of errors from a software product before the first test case is run." ( http://www.computer.org/portal/web/buildyourcareer/fa035 )
He has several related points and extensive discussion in his book 'Facts and Fallacies of Software Engineering'.
One of his key points is that code reviews (he calls them inspections) are the closest thing we have to a silver bullet in a field that actually has very few of them.
Kudos to putting quality first!
The post doesn't talk about these specifics, but a key for us is: "Don’t require perfection. At Khan we prefer getting stuff out early to having it be perfect."
Every single patch is reviewed by (at a minimum) both main devs, and preferably some other people too. The effects are many.
Everyone understands, to some extent, all the code that's committed. We don't end up with black boxes that only one person has any idea about.
A huge number of bugs and bad design decisions are caught. There isn't a programmer in the world who can't benefit from another person's perspective. Code review forces discussion about the choices made in a patch.
Finally, it also lets less-experienced programmers join in; you don't have to be a super hacker in order to comment on parts of a patch, and we welcome comments by literally anyone. There have been many bugs or dubious choices that were found by people who had very little knowledge of the overall codebase.
Working without code reviews is the sign of either an egotistical programmer or a project that has been so resource-crunched that the result will end up as a pile of hacks anyways. I would never recommend it outside of testing and prototyping.
After you have tryed different approaches to solve a particular problem and selected the best one, you want to hand the authority to decline that solution over to somebody who hasn't worked closely at the problem and has looked at only one solution for a few minutes? That can only end badly.
There's a difference between hacking it and doing it right. You hack something to see if it works, and if it does, you discuss it with others and decide the best way to do it right.
One of the largest features I wrote for x264 took 80 minutes to prototype, but a couple weeks of on-and-off work to make it work in all cases, find most of the bugs, and make it efficient. This involved discussing it with other people!
After you have tryed different approaches to solve a particular problem and selected the best one, you want to hand the authority to decline that solution over to somebody who hasn't worked closely at the problem and has looked at only one solution for a few minutes? That can only end badly.
No, that can only end well. If you think that changes to code are better if you don't discuss them with other people, you're simply a terrible programmer. Programming is a team activity, and if you don't trust the other people on your team to read it over and talk about it with you, you or your team are completely dysfunctional.
Conversely, any design decision that you can't justify or explain to someone else when called on it is probably a bad decision.
Your assumption is that "code review" means you hand over the code anonymously, and someone looks at it in isolation and either accepts or rejects it. (At the risk of No True Scotsman-ing) a real code review process involves feedback, questions, and two-way communication. It also requires that other team members be open-minded about other people's code and design decisions, which is a bar that not all dev teams pass.
Now, if you think you won't make any mistakes at all, and any input any other developer might have is garbage compared to what you came up with in the first place...then you're an arrogant developer and I can't imagine anyone wanting to work with you.
There are lots of issues like the 'who can review code' one that affect developers in my situatiojn. Am I in such a minority that the issue doesn't arise for anyone else on HN? I'd love to hear some thoughts on this.
If you're an independent contractor you should be more concerned about getting the volume of work required to have two people on staff.
It gets the benefit of the review mainly by using checklists. Try it: you'll find that forcing yourself to use a checklist mostly eliminates the problem of "I can't find bugs in my own code." You can probably find examples of PSP checklists online. SEI suggests starting with their checklist and modifying it to suit your own needs.
I also explicitly asked this question to some ex-Googler team members about Google's code review culture (similarly required reviews) and heard that rubber stamping is by far the exception even at their size, not the norm.
As far as the incentive: I really don't much like reviewing code either, but the bugs will be found one way or another. Either by you or your customer. Better they be found as soon as possible.
Not surprisingly, the seemingly minor changes can have just as devastating results in production as the major ones.
a) Pre-push: now all your commits are delayed by the review process. Even if it's just by a few minutes, it breaks your flow.
b) Post-push: now if the reviewer things you did it totally wrong, it's too late to fix it. You have to make an entirely new patch, and meanwhile people have been exposed to your already-pushed crap. On the other hand, this is no worse than not reviewing.
In a post-push setup, what do you do with the reviewer's comments?
Or, you can push to stable and deal w/ the exact situation that you describe. We do a lot of the former and a little of the latter.
This is all very well documented within our company and everybody understands the process. The result is that we have cleaner code and fewer bugs in production (although they still get there). It's really just second nature to all developers.
We've been able to develop a very solid set of unit tests and browser-based tests (selenium) that give us a lot of confidence in our releases. Manual testing catches a few things that didn't make it into automated tested, including (but not limited) user interface issues.
1. There's a clear outcome - the change is either approved and carries the name of the reviewer, or it is not. This creates focus and sense of responsibility. Post-push reviews tend to turn into pointless chats followed by no action: "- I think it is better to do it differently. - Yeah, probably, whatever".
2. It's easy to automate them - a simple hook can reject a change that was not reviewed. With post-push you have to nag developers to review every commit, then you have to nag them again to fix whatever the reviewers found, then you have to nag them more to review that fix itself - and so on and on ad nauseum.
3. The quality bar is higher. It is psychologically easier for reviewer to NOT approve something that doesn't look right then to insist that the author fixes it after the fact (asking permission vs forgiveness)
4. Other people don't base their work on code that haven't been reviewed. "yes, you're right, it would be better to do it differently, but now it is used in 150 places, too much trouble to fix" (and next time reviewer won't even bother to mention small problems, the whole process slowly degrades).
5. Most importantly, all code in your shared repo is always reviewed. With post-push, given sufficient volume of commits, there's always some potentially buggy stuff that nobody looked at - and you probably don't even know what it is.
I would even argue that in some teams not reviewing at all would be better then post-push because if you spend time doing reviews, and then nothing happens - you're just wasting time and effort.
Sure, not every organization/startup needs to conform to this practice, but from my experience code reviews help keep developers accountable for the changes they make, and disseminates system knowledge across the team such that no one is a single source of implementation/project knowledge.
I no longer have that misconception.
But, also, strive for a level of code quality that doesn't require that sort of thing.
A system where you put your code up for review, and anyone in the team can review it (like the git pull request system) is fast, effective and a great way to share knowledge in a team.
This one small behavioral change means a world of difference between quality and expertise on the two teams. I'll never work with a team again that doesn't do some form of code review/pull requests etc.
The patch author then adds the "Acked-by" lines to their commit messages (right after their "Signed-off-by"), and pushes the patches.
* if you review other peoples' patches they're more likely to review yours, which means your code is more likely to get committed.
* pointing out a problem and saying 'fix this' or 'have you tested X?' is cheap for you because the patch rework and retesting effort is on the other person. If you don't review and let something dubious through in a bit of code you care about and then have to track down and submit a fix later that's much more effort.
* it builds your reputation with other developers when you spot problems or suggest sensible design improvements. In open source projects this means internet fame. In the company-internal context it probably means better feedback at your next performance review :-)
http://stackoverflow.com/questions/1732348/regex-match-open-...
Something breaks approximately once a day. Yes I am looking for a new job.
http://bronto.com/company/careers
In all honesty, I can tell you right now that code reviews have made me a much better programmer. Mistakes I would make that had to be caught by QA are caught by an extra set of eyes. Also, seeing how other people express their thoughts via code has two benefits. First it opens up your eyes to different ways of doing things and second, it makes you more fluent to other people's code, which makes bugfixes and figuring out intent of code you didn't write much easier.