I'd like to know how often people are doing code reviews and how often you think it is right to do a review. Also, I would like to hear how you perform your code reviews. I'm using TTC for now and I'm quite satisfied with it, but I do not think it is covering all the parts of the code.
Before check in. Check in is often connected with logical finish of function/module (depends on the programmer), so this is a good time. When code is checked in it is already difficult to track down who coded what and when.
Any time any code going to be checked in, so before the check in. However you might want to do it more often than that depending on the project.
If somebody is working on a project that will take weeks and they will not check in any code for that period the code should be received as various components of the project is done. The reason for this is it will have the code continually reviewed to make sure a bad design pattern is not repeated through the entire project and the changes needed from the review are less.
I would also suggest the more junior a developer is the more often the code should be reviewed.
We always perform a code review before code is committed to the trunk. I agree with Neil Butterworth's comment that frequent commits are something to be encouraged and that requiring a code review before every commit inhibits this.
The exact conditions that will work depend on the environment and the project. Our environment is such:
- Keep our mainline of development in the trunk
- Have a rule that trunk must always work (i.e. don't commit things to the trunk that don't compile or fail tests, etc.)
- Branch for each case (feature, bug fix, etc)
- Perform a code review when the work in a given branch is finished
- Merge the branch down into the trunk when it passes review
- When a release is made, we tag the gold release revision and branch. All new bug fixes for a specific release take place in that branch. Release branches are never merged back down into the trunk.
In our environment, this allows the developers to commit often (within the confines of their own branch) and for code reviews to be performed every unit of work (but not every commit).
As to How to conduct a code review, that is a much more ambitious question. One that deserves it's own question on SO (and there are actually already several):
http://stackoverflow.com/questions/89163/how-to-conduct-a-successful-code-review http://stackoverflow.com/questions/457534/best-peer-code-review-software http://stackoverflow.com/questions/tagged/code-review