Code Reviews Inside Out
Zagreb, 21 November 2019
Ines Jelovac Mandarić
Photo by Agence Olloweb on Unsplash
Code review
Benefits
quality assurance
knowledge sharing
time saving & money saving
Benefits
1 hour
of code review prevents
~100 hours
of related work
Document Inspection as an Agent of Change, Holland, 1999
Benefits
Handbook of Walkthroughs, Inspections and Technical Reviews, Freedman and Weinberg, 1990
Benefits
Software Defect-Removal Efficiency, Jones, 1996
Why it works?
1. Psychology:
blind spots
2. Detecting different
kind of problems
Photo by Charles 🇵🇭 on Unsplash
Problems
time consuming
&
money wasting
Photo by Jp Valery on Unsplash
History
Photo by Federica Galli on Unsplash
Today
Photo by Jesus Kiteque on Unsplash
What to review?
● Design
● Functionality
● Complexity
● Tests
● Naming
What to look for in a code review, Google, 2019 Photo by Steven Wright on Unsplash
What to review?
● Comments
● Style
● Documentation
● Check every line
● Context
What to look for in a code review, Google, 2019 Photo by Steven Wright on Unsplash
How to review code?
intuition
&
experience
What is the goal?
Photo by Fab Lentz on Unsplash
How to give feedback?
● Writing comments
○ Change request
○ Informational comment
● Talking
When to review?
One
bussiness day
Speed of Code Reviews, Google, 2019 Photo by Nathan Dumlao on Unsplash
How NOT to review code?
● Looking for typos
● Checking format
● Detecting dead code
How NOT to review code?
● Checking if it compiles
● Checking if it runs
● Checking if tests run
How NOT to review code?
● Focusing on bugs 🐛
● Discussing alternatives
How to prepare code for review?
● Submitting small amount of changes
● Self-review first
● Not relying on reviewer too much
● Writing good description
How to choose a reviewer?
● expert in technology used
● expert in domain
Who should review your code?
senior ➔ junior
junior ➔ senior
peer ➔ peer
Photo by Icons8 Team on Unsplash
Who should
NOT review
code?
managers
How many people should review code?
max 3
The Jet Propulsion Laboratory’s Experience with Formal Inspections, Bush and Kelly, 1989.
An Experiment to Assess Different Defect Detection Methods for Software Requirements Inspections, Porter and
Votta, 1994.
Recap
Reviewers
● Focus on quality
● Remember to talk
● Respond quickly
Authors
● Prepare code
before review
● Choose reviewer(s)
wisely and not too
many
Human factor
Photo by Sebastian Herrmann on Unsplash
For reviewers
● Short and clear
comments
● Stay objective
● Don't criticize
● Focus on problems, not
solutions
● Modify feedback
● Positive feedback
Photo by Ben White on Unsplash
For authors
● Understand comment
● Ask for extra info
● Appreciate feedback
● Learn and improve!
Photo by Ben White on Unsplash
General approach
● Show respect
● Don't take it personally
● Don't make it personal
● Identify problems in processes/organization
● Code review is not performance review!
Variations
Work in progress
● Incomplete work
● Early feedback
● Discuss alternatives
Photo by Josue Isai Ramos Figueroa on Unsplash
Pair programming
● Type of in-person review
● Live session
Photo by Brooke Cagle on Unsplash
Summary
● Improve code quality
● Automate what possible
● Give good feedback
● Professional peer to peer approach
● Learn from mistakes
Image from http://thedataist.com/ten-good-coding-practices-for-data-scientists/
Conclusion
Resources
● Code Complete, Steve McConnell, 2004
● Design and Code Inspections to Reduce
Errors in Program Development by Michael
Fagan, 1976
● Code Review Developer Guide, Google, 2019

Code Reviews Inside Out