Wednesday, February 14, 2007

Why Code Reviews Are So Important

Yesterday I spent five hours participating in a hard core code review / bug fix session. The code we were reviewing was rather small, but there were a lot of cases to test. Code reviews can be structured in many different ways, but we took the following approach:

1. Review the functional specification to understand the goals of the project
2. Run a few preliminary test cases to make sure the product met the goals
3. Compare every screen to the designs to make sure they were 100% correct (right fonts, colors, wording)
4. Fix bugs on the spot. This was the most time consuming part, but I'm glad we did this right away, avoiding having to hold another session the following day.
5. This project was primarily modifying existing code to add additional functionality. This means that we can use trac in combination with svn to review only the changes made to each file. This makes the code review process very thorough and very fast. Trac does a great job color coding differences and we were able to find a dozen or so typos and bugs simply from looking at the trac diffs. We fixed the bugs right away, committed the code, and repeated the process.
6. After we finished fixing all of the bugs we went through a more thorough testing of the entire application to make sure we didn't break anything and that all of the bugs discovered were indeed fixed.

Overall I was very pleased with the results. The code review not only produced many bug fixes, but it emphasizes the importance of good coding, documenting your code, and being able to work with others.