Categories: Contributing | Development | MySQLUniversity

How to do a good code review

← Back to MySQL University main page

Contents

[edit] Presentation

  • What's the purpose of a code review ?
    • is it a bug ? should it be fixed ? if yes - how  ?
      • read the bug description first!
    • is the proposed solution correct ? in the right place ?
    • does it fix the bug or hides it ?
    • is it implemented correctly ?
    • follows our coding guidelines
    • compatible with the future roadmap and the vision
    • doesn't duplicate existing code or functionality
    • is optimal, efficiently implemented
      • most attention to the tight loops
      • rarely used code can use relaxed criteria
    • properly commented
      • all non-trivial parts MUST be commented
      • if some place makes me think "why" - it needs a comment
      • changeset comment must have bug/wl number and subject
      • and short summary of a problem/changes
    • properly tested
      • the test matches the bug description (check!)
      • the test FAILS without a fix
        • create a test first, then fix the bug. Then update the result file.
      • as a reviewer I assume that the code compiles, without warnings, and is tested
  • BUT NOT
    • the purpose of a review is NOT to force a developer to write YOUR patch
    • developer writes HIS patch
    • been there, done that
  • Rules
    • you can only review the code that you're familiar with
    • you don't understand - you don't approve!
    • educate the coder - if the patch is wrong, explain
    • the reviewer is ultimately responsible for the code
  • Warning signal
    • incompatible change in behavior
      • ... or file formats
      • ... or index ordering (requires REPAIR)
    • fix for a boundary case introduces a noticeable overhead in the common case
    • changes many existing test results
    • changes more than necessary
      • especially in GA code
  • Remember Common Pitfalls
  • Tips and Tricks
    • diff -p
    • rediff (in internals)
    • diff folding in vim (in internals)

[edit] Questions

[edit] Questions asked before the session

  1. (joro) What is the preferred form of a bug fix review ? Should it always be a reply to the commit e-mail ?
    • YES.
  2. (joro) What is the preferred form of a request for a bug fix review ? Forward of the commit e-mail ?
    • No. But at least, not for me. Subject line only?
  3. (joro) What about estimates ? Should the reviewer fill/update the est. completion field in the bug ?
    • I don't do that but, yes, if it will take a long time.
    • For a short time no estimate is necessary. A big patch should be in the WorkLog.

[edit] Questions asked during the session

  1. Question: Are there checklists that reviewers could use / should use?
  2. Question: Do reviewers normally use that list already?
    • I doubt it :) but I don't know, really.

[edit] Voice recording and other links

[edit] Heidelberg Broadcast Sept 20, 2007

Scribe: Peter Lavin

[edit] Remarks

Need an overview of what is going on to determine the action to take.

Description should be an abstract -- don't say too much.

Sometimes you can add assertions for help debugging.

When adding new files make sure they are part of "makedist"

[edit] Questions

Retrieved from "http://forge.mysql.com/wiki/How_to_do_a_good_code_review"

This page has been accessed 4,286 times. This page was last modified 08:31, 26 September 2007.

Find

Browse
MySQLForge
Main Page
Current events
Recent changes
Random page
Help
Edit
Edit this page
Editing help
This page
Discuss this page
Post a comment
Printable version
Context
Page history
What links here
Related changes
My pages
Special pages
New pages
File list
Statistics
Bug reports
More...