Software Engineering at Google Chapter #9 - Code Review (3 of 3)

  • Write small changes that are about 200 lines of code so one can easily determine the source of a bug
  • Prefer small changes, but sometimes large changes are unavoidable (introducing a new feature)
  • Two important aspects of good change descriptions:
    • First line should act as a summary
    • Description of the change should say what is being changed and importantly, why it is being changed
  • Keep reviewers to a minimum
  • Static analysis is one of Google’s “most important” changes over the years
  • Getting input from additional engineers “just in case” has diminishing returns
  • Automate where possible (syntax checkers, linters, auto-style checkers, etc (these checks usually happen pre-submit))
  • Types of Code Reviews (Greenfield code, bux fixes and rollbacks, and behavioral changes / improvements / ptimizations)
  • Greenfield Code Reviews
  • “Greenfield” means all new or 100% new code
  • This is the most important time to analyze and make changes so your code stands the test of time
  • New code should solve a problem, not provide an alternative
  • Do a design review before the first code review
  • Bug Fixes and Rollbacks
  • Only fix the bug, don’t attempt to fix other things at the same time. Makes regression testing harder
  • Be sure to update the tests (modify existing and add new if necessary)
  • Consider allowing internal customers to rollback code changes that created downstream issues for them
  • If you depend on new code very quickly after it’s deployed, it makes it harder to rollback (as others will be using the new code and you will break their stuff)
  • Behavioral Changes, Improvements, and Optimizations
  • Update your code tests (unit, integration, etc)
  • Re-benchmark if optimizing
  • The Refactorings and Large-scale Changes section rambles on about how many code changes are automatically generated at Google but presents no real details
< BACK NEXT >
Tweet


   


   

Thank you for your time and attention.
Apply what you've learned here.
Enjoy it all.