THE ANATOMY OF A CODETHE ANATOMY OF A CODE
REVIEWREVIEW
GUILHERME GARNIERGUILHERME GARNIER
@gpgarnier
https://blog.guilhermegarnier.com
We're hiring!
@gpgarnier
https://blog.guilhermegarnier.com
https://sobre.jusbrasil.com.br/carreiras
A TRADITIONAL CI PIPELINEA TRADITIONAL CI PIPELINE
ADDING CODE REVIEWADDING CODE REVIEW
WHAT'S A CODE REVIEW?WHAT'S A CODE REVIEW?
A tool to:
improve code quality
share knowledge about the project
share knowledge about technologies, libraries, etc
CODE REVIEW WORKFLOWCODE REVIEW WORKFLOW
CODE REVIEW WORKFLOWCODE REVIEW WORKFLOW
CODE REVIEW WORKFLOWCODE REVIEW WORKFLOW
CODE REVIEW WORKFLOWCODE REVIEW WORKFLOW
CODE REVIEW WORKFLOWCODE REVIEW WORKFLOW
CODE REVIEW WORKFLOWCODE REVIEW WORKFLOW
CODE REVIEW CHECKLISTCODE REVIEW CHECKLIST
CODE REVIEW CHECKLISTCODE REVIEW CHECKLIST
Does the code do what it’s supposed to do?
CODE REVIEW CHECKLISTCODE REVIEW CHECKLIST
Does the code do what it’s supposed to do?
Is it bug free?
CODE REVIEW CHECKLISTCODE REVIEW CHECKLIST
Does the code do what it’s supposed to do?
Is it bug free?
Is it expressive?
CODE REVIEW CHECKLISTCODE REVIEW CHECKLIST
Does the code do what it’s supposed to do?
Is it bug free?
Is it expressive?
Is it scalable?
CODE REVIEW CHECKLISTCODE REVIEW CHECKLIST
Does the code do what it’s supposed to do?
Is it bug free?
Is it expressive?
Is it scalable?
Does it follow the projects conventions and standards?
CODE REVIEW CHECKLISTCODE REVIEW CHECKLIST
Does the code do what it’s supposed to do?
Is it bug free?
Is it expressive?
Is it scalable?
Does it follow the projects conventions and standards?
Is it well tested? Does it handle corner cases?
BENEFITSBENEFITS
to the code author
to the reviewer
to the team
BENEFITS TO THE CODE AUTHORBENEFITS TO THE CODE AUTHOR
BENEFITS TO THE CODE AUTHORBENEFITS TO THE CODE AUTHOR
Learn about the project
BENEFITS TO THE CODE AUTHORBENEFITS TO THE CODE AUTHOR
Learn about the project
Learn about the technologies involved
BENEFITS TO THE CODE AUTHORBENEFITS TO THE CODE AUTHOR
Learn about the project
Learn about the technologies involved
Learn other ways to solve problems
BENEFITS TO THE CODE AUTHORBENEFITS TO THE CODE AUTHOR
Learn about the project
Learn about the technologies involved
Learn other ways to solve problems
Learn to accept critics
BENEFITS TO THE REVIEWERBENEFITS TO THE REVIEWER
BENEFITS TO THE REVIEWERBENEFITS TO THE REVIEWER
Learn about the changes
BENEFITS TO THE REVIEWERBENEFITS TO THE REVIEWER
Learn about the changes
Learn about the project
BENEFITS TO THE REVIEWERBENEFITS TO THE REVIEWER
Learn about the changes
Learn about the project
Learn about the technologies involved
BENEFITS TO THE REVIEWERBENEFITS TO THE REVIEWER
Learn about the changes
Learn about the project
Learn about the technologies involved
Develop a critical view of someone else's code
BENEFITS TO THE TEAMBENEFITS TO THE TEAM
BENEFITS TO THE TEAMBENEFITS TO THE TEAM
Shared code ownership
BENEFITS TO THE TEAMBENEFITS TO THE TEAM
Shared code ownership
Helps keeping standards
STARTING CODE REVIEWSSTARTING CODE REVIEWS
EACH PR SHOULD BE A COHESIVE UNITYEACH PR SHOULD BE A COHESIVE UNITY
easier to get context
easier to revert, if needed
READABILITY IS VERY IMPORTANTREADABILITY IS VERY IMPORTANT
make you code/test/docs as clear as possible
add context do your PR description (images, link to issues)
MAKE PRS AS SMALL AS POSSIBLEMAKE PRS AS SMALL AS POSSIBLE
RECEIVING CODE REVIEWSRECEIVING CODE REVIEWS
Be humble and thankful
Start discussions when needed
REVIEWING CODE REVIEWSREVIEWING CODE REVIEWS
TAKE TIME TO REVIEW, DON'T RUSHTAKE TIME TO REVIEW, DON'T RUSH
WATCH FOR DETAILSWATCH FOR DETAILS
DON'T BE LIMITED TO CRITICSDON'T BE LIMITED TO CRITICS
RECOGNIZE GOOD DECISIONSRECOGNIZE GOOD DECISIONS
IN CASE OF DOUBT, ASKIN CASE OF DOUBT, ASK
COMMON PROBLEMS ANDCOMMON PROBLEMS AND
CONCERNSCONCERNS
COMMON PROBLEMS ANDCOMMON PROBLEMS AND
CONCERNSCONCERNS
Won’t this slow me down?
COMMON PROBLEMS ANDCOMMON PROBLEMS AND
CONCERNSCONCERNS
Won’t this slow me down?
How to handle large pull requests?
COMMON PROBLEMS ANDCOMMON PROBLEMS AND
CONCERNSCONCERNS
Won’t this slow me down?
How to handle large pull requests?
How many reviewers do I need?
COMMON PROBLEMS ANDCOMMON PROBLEMS AND
CONCERNSCONCERNS
Won’t this slow me down?
How to handle large pull requests?
How many reviewers do I need?
Do I need code reviews if I pair program?
COMMON PROBLEMS ANDCOMMON PROBLEMS AND
CONCERNSCONCERNS
Won’t this slow me down?
How to handle large pull requests?
How many reviewers do I need?
Do I need code reviews if I pair program?
When not to use code reviews?
CONCLUSIONSCONCLUSIONS
CONCLUSIONSCONCLUSIONS
Code reviews can make you slower in the short term
CONCLUSIONSCONCLUSIONS
Code reviews can make you slower in the short term
but faster in the long term
CONCLUSIONSCONCLUSIONS
Code reviews can make you slower in the short term
but faster in the long term
It helps onboarding new people
CONCLUSIONSCONCLUSIONS
Code reviews can make you slower in the short term
but faster in the long term
It helps onboarding new people
It helps sharing knowledge
CONCLUSIONSCONCLUSIONS
Code reviews can make you slower in the short term
but faster in the long term
It helps onboarding new people
It helps sharing knowledge
It helps sharing code ownership
CONCLUSIONSCONCLUSIONS
Code reviews can make you slower in the short term
but faster in the long term
It helps onboarding new people
It helps sharing knowledge
It helps sharing code ownership
Reviewing code is also part of your job
LINKSLINKS
The anatomy of a code review:
TDC SP 2019 - Decodi cando o code review:
Google's Code Review Developer Guide:
Lessons From Google: How Code Reviews Build Company Culture:
Why junior devs should review seniors’ commits:
Anatomy Of A Code Review:
https://blog.guilhermegarnier.com/2018/05/the-
anatomy-of-a-code-review/
https://speakerdeck.com/elainenaomi/tdc-sp-2019-decodi cando-o-code-review
https://google.github.io/eng-
practices/review/
https://blog.fullstory.com/what-we-learned-from-google-code-reviews-arent-just-for-
catching-bugs/
https://pagefault.blog/2018/04/08/why-junior-devs-should-review-seniors-commits/
https://speakerdeck.com/asendecka/anatomy-of-a-
code-review
THANK YOU!THANK YOU!
Slides:
https://blog.guilhermegarnier.com
@gpgarnier
https://blog.guilhermegarnier.com/talk-code-review/

The Anatomy of a Code Review