Tuesday, March 28, 2017

The Value of Code Reviews

I have recently seen code that that looked like this.
  ... Lines of Code here ...
procedure TCustomClass.MethodDoThis()
  ... 20 Lines of code ...

procedure TCustomClass.MethodDoThis2()
  ... Same 20 Lines of code with slight modification ...
Both produced code that may have passed end user testing. But both cause long-term problems.
  • The first example was just hiding all exceptions, a bad practice. After the code review, it was determined that the try | except block was not even needed.
  • The second example was refactored to reduce the need for duplicate code. The duplicate code causes problems when someone has to make changes that would apply to both methods but does not notice the 2nd method and therefore neglects to change it.
My point is simple, code reviews have value.

Sidenote: Looking forward to reviewing Tokyo release of Delphi soon. With 500+ Bug Fixes with many in areas that impact our system is definitely worth investigating. Security and Quality go hand in hand, and I appreciate work to improve security. Typically, security issues are related to bugs in code that are exploited by hackers.