SlideShare a Scribd company logo
—
Trisha Gee (@trisha_gee)
Developer & Technical Advocate, JetBrains
Code Review
Best Practices
Code Review Best Practices
Code Review Best Practices
This code works
Having Opinions On Code Is An
Occupational Hazard
Having Opinions On Code Is An
Occupational Requirement
Are we harder on other people’s code
than our own?
What to look for in a code review
http://jb.gg/book/codereview
• Gateway Reviews
• Knowledge Sharing
• Early Design Feedback
Different workflows
https://blog.jetbrains.com/upsource/tag/code-review-workflows/
What should you look for when
reviewing code?
It Depends
My First Code Review
My job is to Find Problems
Anti-Pattern
Nit picking
Anti-Pattern
Design changes when the code works
Anti-Pattern
Inconsistent feedback
Anti-Pattern
The Ghost Reviewer
Anti-Pattern
Ping pong reviews
Developers hate code reviews
Code Reviews are a
Massive Waste of Time
1. Why?
Ensure code meets standards
Find bugs
Share knowledge
Check code is understandable
Ensure code does what it’s supposed to
Collaborate on design
Evolve application code
2. When?
• During implementation?
• When it’s ready to merge?
• After it’s been merged?
When do you review?
• When everyone agrees?
• When a gatekeeper agrees?
• When all comments are addressed?
When is the review complete?
3. Who?
Who reviews the code?
Who signs it off?
4. Where?
Pairing
Showing code to a colleague at a
computer
Mob reviewing in a conference room
Remote screen-sharing
In the IDE, checking out a commit or
branch
Using code review software
5. What?
1. Why
2. When
3. Who
4. Where
Requires you to know:
• Fit with the overall architecture
• SOLID principles, Domain Driven Design, Design Patterns or other paradigms of choice
• New code follows team’s current practices
• Code is in the right place
• Code reuse
• Over-engineering
• Readable code and tests
• Testing the right things
• Exception error messages
• Subtle bugs
• Security
• Regulatory requirements
• Performance
• Documentation and/or help files been updated
• Spelling, punctuation & grammar on user messages
What to look for
https://blog.jetbrains.com/upsource/tag/what-to-look-for/
Human reviewers should be doing what
cannot be automated
Understand the constraints
Why: Knowledge Sharing
Purpose isn’t to reject the code
Why: Knowledge Sharing
Focus is on how easy it is to understand
the code
When: At the end
Too late for design
When: At the end
Should have specific checks
6. How?
Automate Everything You Can
Submitting for review
Annotate your code
Submitting for review
Reviews should be small
Reviewing
Should be clear Who is reviewing
Reviewing
Respond in a timely fashion
Reviewing
Checklist of What to look for
Comments
Bear in mind Why, When and What
Comments
Be constructive
Comments
Be specific
Accept or Reject
Accept or Raise Concern
Next steps should be clear
Making changes
Respond in a timely fashion
Making changes
Respond to comments
Resolving
The goal is to accept the review
Resolving
Should be clear Who signs it off
Resolving
…and When
Have Clear Objectives
1. Why
2. When
3. Who
4. Where
5. What
6. How
Clarity Comes From Understanding
Not to prove how clever you are
The Goal Is To Ship The Code
http://bit.ly/CRGood

More Related Content

What's hot (20)

PPTX
Code Review
Mikalai Alimenkou
 
DOCX
Code review guidelines
Lalit Kale
 
PDF
Code review best practice
Oren Digmi
 
PPTX
Code Review
R M Shahidul Islam Shahed
 
PPT
Code Quality
François Camus
 
PDF
API for Beginners
Gustavo De Vita
 
PPTX
Api Testing
Vishwanath KC
 
PPTX
SonarQube.pptx
YASHWANTHGANESH1
 
PPTX
Test Automation Framework with BDD and Cucumber
Rhoynar Software Consulting
 
PPT
Clean code
Uday Pratap Singh
 
PPT
SonarQube Overview
Ahmed M. Gomaa
 
PPTX
Software development best practices & coding guidelines
Ankur Goyal
 
PDF
Test Driven Development (TDD)
David Ehringer
 
PPTX
Microservices Architecture & Testing Strategies
Araf Karsh Hamid
 
PDF
User Interface Testing. What is UI Testing and Why it is so important?
Maveryx
 
PDF
Introduction to CICD
Knoldus Inc.
 
PPT
Automated Testing vs Manual Testing
didev
 
PDF
Design patterns for microservice architecture
The Software House
 
PPTX
Test-Driven Development
John Blum
 
PDF
Application Monitoring using Datadog
Mukta Aphale
 
Code Review
Mikalai Alimenkou
 
Code review guidelines
Lalit Kale
 
Code review best practice
Oren Digmi
 
Code Quality
François Camus
 
API for Beginners
Gustavo De Vita
 
Api Testing
Vishwanath KC
 
SonarQube.pptx
YASHWANTHGANESH1
 
Test Automation Framework with BDD and Cucumber
Rhoynar Software Consulting
 
Clean code
Uday Pratap Singh
 
SonarQube Overview
Ahmed M. Gomaa
 
Software development best practices & coding guidelines
Ankur Goyal
 
Test Driven Development (TDD)
David Ehringer
 
Microservices Architecture & Testing Strategies
Araf Karsh Hamid
 
User Interface Testing. What is UI Testing and Why it is so important?
Maveryx
 
Introduction to CICD
Knoldus Inc.
 
Automated Testing vs Manual Testing
didev
 
Design patterns for microservice architecture
The Software House
 
Test-Driven Development
John Blum
 
Application Monitoring using Datadog
Mukta Aphale
 

Similar to Code Review Best Practices (20)

PPTX
Effective Code Review
Jane Prusakova
 
PDF
Automated Code Reviews with AI and ML - DevOps Next
Perfecto by Perforce
 
PPTX
Code review at large scale
Mikalai Alimenkou
 
PDF
code_review_checklist_6_actions_to_improve_the_quality_of_your_reviews.pdf
sarah david
 
PPTX
code_review_checklist_6_actions_to_improve_the_quality_of_your_reviews.pptx
sarah david
 
PPTX
Capability Building for Cyber Defense: Software Walk through and Screening
Maven Logix
 
PPTX
Code review
Aleksey Solntsev
 
PPTX
Code reviews
Robert Lee
 
PDF
Code Review Matters and Manners
Trisha Gee
 
PPTX
Code_Review_Presentation_v22222_LLM.pptx
SofienBoutaib
 
PDF
Effective code reviews
nextbuild
 
PDF
Code Review for iOS
KLabCyscorpions-TechBlog
 
PDF
Software Defect Prevention via Continuous Inspection
Josh Gough
 
PPTX
Code Reviews
phildenoncourt
 
PPTX
You cant be agile if your code sucks
Peter Gfader
 
PPTX
A Brief Introduction to Test-Driven Development
Shawn Jones
 
PPTX
Peer review
Charuta Joshi
 
PDF
Code Review: How and When
Paul Gower
 
PDF
On to code review lessons learned at microsoft
Michaela Greiler
 
PDF
Xen Project Contributor Training - Part 1 introduction v1.0
The Linux Foundation
 
Effective Code Review
Jane Prusakova
 
Automated Code Reviews with AI and ML - DevOps Next
Perfecto by Perforce
 
Code review at large scale
Mikalai Alimenkou
 
code_review_checklist_6_actions_to_improve_the_quality_of_your_reviews.pdf
sarah david
 
code_review_checklist_6_actions_to_improve_the_quality_of_your_reviews.pptx
sarah david
 
Capability Building for Cyber Defense: Software Walk through and Screening
Maven Logix
 
Code review
Aleksey Solntsev
 
Code reviews
Robert Lee
 
Code Review Matters and Manners
Trisha Gee
 
Code_Review_Presentation_v22222_LLM.pptx
SofienBoutaib
 
Effective code reviews
nextbuild
 
Code Review for iOS
KLabCyscorpions-TechBlog
 
Software Defect Prevention via Continuous Inspection
Josh Gough
 
Code Reviews
phildenoncourt
 
You cant be agile if your code sucks
Peter Gfader
 
A Brief Introduction to Test-Driven Development
Shawn Jones
 
Peer review
Charuta Joshi
 
Code Review: How and When
Paul Gower
 
On to code review lessons learned at microsoft
Michaela Greiler
 
Xen Project Contributor Training - Part 1 introduction v1.0
The Linux Foundation
 
Ad

More from Trisha Gee (20)

PPTX
Career Advice for Architects
Trisha Gee
 
PPTX
Is boilerplate code really so bad?
Trisha Gee
 
PDF
Career Advice for Programmers - ProgNET London
Trisha Gee
 
PDF
Is Boilerplate Code Really So Bad?
Trisha Gee
 
PPTX
Real World Java 9 - JetBrains Webinar
Trisha Gee
 
PDF
Real World Java 9
Trisha Gee
 
PPTX
Real World Java 9
Trisha Gee
 
PPTX
Career Advice for Programmers
Trisha Gee
 
PPTX
Real World Java 9
Trisha Gee
 
PPTX
Becoming fully buzzword compliant
Trisha Gee
 
PDF
Real World Java 9 (QCon London)
Trisha Gee
 
PPTX
Java 9 Functionality and Tooling
Trisha Gee
 
PDF
Java 8 and 9 in Anger
Trisha Gee
 
PDF
Refactoring to Java 8 (Devoxx BE)
Trisha Gee
 
PDF
Refactoring to Java 8 (QCon New York)
Trisha Gee
 
PDF
Refactoring to Java 8 (Devoxx UK)
Trisha Gee
 
PDF
Staying Ahead of the Curve
Trisha Gee
 
PPTX
Level Up Your Automated Tests
Trisha Gee
 
PDF
Java 8 in Anger (JavaOne)
Trisha Gee
 
PPTX
Staying Ahead of the Curve
Trisha Gee
 
Career Advice for Architects
Trisha Gee
 
Is boilerplate code really so bad?
Trisha Gee
 
Career Advice for Programmers - ProgNET London
Trisha Gee
 
Is Boilerplate Code Really So Bad?
Trisha Gee
 
Real World Java 9 - JetBrains Webinar
Trisha Gee
 
Real World Java 9
Trisha Gee
 
Real World Java 9
Trisha Gee
 
Career Advice for Programmers
Trisha Gee
 
Real World Java 9
Trisha Gee
 
Becoming fully buzzword compliant
Trisha Gee
 
Real World Java 9 (QCon London)
Trisha Gee
 
Java 9 Functionality and Tooling
Trisha Gee
 
Java 8 and 9 in Anger
Trisha Gee
 
Refactoring to Java 8 (Devoxx BE)
Trisha Gee
 
Refactoring to Java 8 (QCon New York)
Trisha Gee
 
Refactoring to Java 8 (Devoxx UK)
Trisha Gee
 
Staying Ahead of the Curve
Trisha Gee
 
Level Up Your Automated Tests
Trisha Gee
 
Java 8 in Anger (JavaOne)
Trisha Gee
 
Staying Ahead of the Curve
Trisha Gee
 
Ad

Recently uploaded (20)

PDF
Generative AI vs Predictive AI-The Ultimate Comparison Guide
Lily Clark
 
PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PDF
Per Axbom: The spectacular lies of maps
Nexer Digital
 
PDF
TrustArc Webinar - Navigating Data Privacy in LATAM: Laws, Trends, and Compli...
TrustArc
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PDF
introduction to computer hardware and sofeware
chauhanshraddha2007
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PPTX
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
PDF
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PPTX
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
PDF
The Future of Artificial Intelligence (AI)
Mukul
 
PPTX
Simple and concise overview about Quantum computing..pptx
mughal641
 
Generative AI vs Predictive AI-The Ultimate Comparison Guide
Lily Clark
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
Per Axbom: The spectacular lies of maps
Nexer Digital
 
TrustArc Webinar - Navigating Data Privacy in LATAM: Laws, Trends, and Compli...
TrustArc
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
introduction to computer hardware and sofeware
chauhanshraddha2007
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
The Future of Artificial Intelligence (AI)
Mukul
 
Simple and concise overview about Quantum computing..pptx
mughal641
 

Code Review Best Practices

Editor's Notes

  • #3: argh my eyes
  • #5: And it’s tested. And performance doesn’t really matter
  • #8: I think we’re harder on code when we read it than when we write it Reading code is hard We could use some guidelines and ideas
  • #9: This is what people automatically think of And this is the first blog post I was asked to write for Upsource
  • #10: In fact, turned out to be such a big topic that I wrote a whole series of blog posts, that got turned into a book The more I looked into it the more I realised that this was impossible. No-one could list everything that needs to be checked, no code could pass every check
  • #13: The real answer is, it depends One size does not fit all
  • #14: STORY: Code Review at UBS - Didn’t know what I should be looking for - Took it as my opportunity to forward my own ideas (e.g. unit testing, clean code)
  • #15: Can be solved with automation
  • #16: Understand when the review happens
  • #17: Inconsistent between reviewers, but even from the same reviewer Happens when there’s no guidelines or goals
  • #18: Because reviewing code is hard and boring And because we generally don’t get rewarded for reviewing code
  • #19: No understanding of what “Done” looks like I could go on but that is not this talk
  • #20: As an author you’re already in a place of vulnerability And as a reviewer it just break your flow and it’s hard to read code you didn’t write. - Stops code going into production - Code doesn't necessarily get better - We don’t get better Code reviews massive waste of time
  • #21: Which is why everyone focuses on telling you how important it is to do them, instead of how to do them well
  • #23: Couldn’t this be automated? What are the standards?
  • #24: Much can be automated but mission critical systems obviously benefit from human reviewers as well Look for gotchas: people experienced in the codebase can see if someone’s doing something that seems right but will have unintended consequences If your code is clean and easy to reason about, if you have good automated tests, you should need to spend very little time on this
  • #25: To increase the bus factor
  • #26: Not necessarily the same Here one or more people check the code to see if it could theoretically be understood by others
  • #27: Can’t be automated
  • #28: To evolve the code together
  • #29: Could use code reviews to enforce cleaning of tech debt as you go, or migrating a legacy system. Rules like: - Cleaning the method you’re in - addressing any warnings (or suppressed warnings) for this code - also may need rules about what’s committed and how (e.g. formatting changes / warnings changes are a separate commit) You can’t automate any of this!
  • #31: This depends upon the goals
  • #32: When we’re so bored we give up?
  • #33: Who reviews the code? Who’s responsible for signing off? Is a single “no” a veto, or is there another process?
  • #34: Is it the same people every time? A set of experts? Or a rotating pool? Do people have areas of expertise? Assignment can be automatic based on: - who’s the author - which code was touched - which branch was touched Watchers vs reviewers
  • #35: One person? A committee? Is it all or nothing? Or a veto system? How are deadlocks resolved?
  • #36: Where the team is located and where the reviewers are located impacts your code review process And where you do the code review
  • #37: My favourite
  • #38: If you’re located in the same office Forces you to be nice
  • #39: Forces input from many Forces resolution of deadlock?
  • #40: Via skype or slack or hangouts Don’t have to be collocated but have to have overlapping timezones
  • #41: Can be fully async, works for remote and unfriendly timezones
  • #42: Also includes GitHub pull requests Also fully async
  • #43: To look for in a code review We can only identify this once we know the answers to the other questions And it shouldn’t be a wishlist of everything
  • #45: For example, if the code is related to Orders, is it in the Order Service? If so, should it be refactored to a more reusable pattern, or is this acceptable at this stage? How does the team balance considerations of reusability with YAGNI? Are confusing sections of code either documented, commented, or covered by understandable tests (according to team preference)? Is the code going to accidentally point at the test database, or is there a hardcoded stub that should be swapped out for a real service?
  • #47: System constraints: - Internal systems hosted on safe hardware don’t need the same level of security checks - Web applications don’t need (the same) low latency performance - If you do have regulatory requirements these should be worked into the code review (or automated) – e.g. audit
  • #50: Checking design needs to be factored into the process some other way Like up front design Or a whiteboarding session
  • #51: There shouldn’t be any surprises
  • #53: Formatting checks, applying formatting The build Testing - Unit, integration, end to end, performance, security Deployment
  • #57: Use due dates if possible
  • #58: And priority Aligned with code review goals and constraints MOSCOW - Must Should Could Would
  • #59: Why are we doing this code review When is it being done What are we looking for
  • #60: Be nice. If you’re nice, the author is more likely to listen Comments should relate to the code, not the author Can also leave praise
  • #61: What actions need to be taken What priority are they (labels, colours)
  • #62: What actions need to be taken What priority are they (labels, colours)
  • #63: Concerns listed and prioritised Can’t reject without comments MOSCOW When you know Why, When, Who, Where, What it should be clear whether it’s accepted or not And what the next steps are
  • #64: Minimise cognitive load/context switching Prioritised feedback should make this easier And always respond to questions as fast as you can (even if it’s I’ll get back to you) – don’t be the ghost reviewer
  • #65: And resolve answered discussions
  • #66: Resolve as fast as possible. The goal is to accept the code, not to make it wait in line
  • #67: Who decides when the code is good to go? All reviewers or some? Any power of veto
  • #68: If next steps / actions were clear, if priorities were clear, it should be easy to understand when the review is good to go
  • #69: Objectives = consistency Objectives means fewer surprises, greater consistency Also can lead to code that meets those requirements before entering review
  • #70: You can’t have sensible answers to any of these without knowing why first Only when you’ve answered the first 4 can you sensibly know what to look for and create guidelines on how to do the code review. If you have no control over the code review process but don’t know the asnwers to these questions, ask someone.
  • #71: Does it do what it’s supposed to do? Is there anything horribly wrong with it? Does adding this feature/fixing this bug add more value than any debt introduced by maintaining this code?