Wednesday, 26 August 2015

Code Review - Where To Start

I really enjoyed reading: What To Look For In A Code Review - it touches on something I do everyday and is a skill I really want to hone.

One of the things I have learnt is code review should never start with looking at what the code does or even how it does it. Take this snippet for example:

There are many things you could comment on:
  • The insane mixture of camelCase and underscores
  • A curious use of the package-private visibility
  • Rather disturbing presence of the Singleton annotation
Whilst all these questions are very valid, without proper context they may prove to be completely redundant! Building up this context is where a code review should start, establish:
  • Why is the code needed?
  • What is the underlying problem being solved?
This information shouldn't be limited to the code review either, the code should communicate this for any future readers.

No comments:

Post a Comment