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

PPS
Unit Testing
Anuj Arora
 
PPTX
Code review
Abhishek Sur
 
PDF
How to successfully grow a code review culture
Nina Zakharenko
 
PDF
Documenting Software Architectures
Paulo Gandra de Sousa
 
PPTX
Coding standards for java
maheshm1206
 
PPT
Code coverage
Return on Intelligence
 
PPT
Code Quality
François Camus
 
PPTX
Code smell overview
Pham Manh Lan
 
Unit Testing
Anuj Arora
 
Code review
Abhishek Sur
 
How to successfully grow a code review culture
Nina Zakharenko
 
Documenting Software Architectures
Paulo Gandra de Sousa
 
Coding standards for java
maheshm1206
 
Code coverage
Return on Intelligence
 
Code Quality
François Camus
 
Code smell overview
Pham Manh Lan
 

What's hot (20)

PPTX
Code Review
Mikalai Alimenkou
 
DOCX
Code review guidelines
Lalit Kale
 
PPTX
Coding standards and guidelines
brijraj_singh
 
PPS
Coding Best Practices
mh_azad
 
PPTX
Improving Code Quality Through Effective Review Process
Dr. Syed Hassan Amin
 
PDF
Clean code
Achintya Kumar
 
PPTX
Code Review
R M Shahidul Islam Shahed
 
PPTX
Coding conventions
systemcrashed
 
PPTX
Coding standards
Mark Reynolds
 
PPTX
Clean Code - The Next Chapter
Victor Rentea
 
PPTX
Spring Boot
Jiayun Zhou
 
PDF
Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010
Atlassian
 
PPTX
Coding standard and coding guideline
Dhananjaysinh Jhala
 
PDF
Testing Angular
Lilia Sfaxi
 
PPTX
Software Quality
Ronald Harmsen
 
PPTX
Software development best practices & coding guidelines
Ankur Goyal
 
KEY
Clean code and Code Smells
Mario Sangiorgio
 
PPTX
BDD WITH CUCUMBER AND JAVA
Srinivas Katakam
 
PDF
Test Driven Development (TDD)
David Ehringer
 
Code Review
Mikalai Alimenkou
 
Code review guidelines
Lalit Kale
 
Coding standards and guidelines
brijraj_singh
 
Coding Best Practices
mh_azad
 
Improving Code Quality Through Effective Review Process
Dr. Syed Hassan Amin
 
Clean code
Achintya Kumar
 
Coding conventions
systemcrashed
 
Coding standards
Mark Reynolds
 
Clean Code - The Next Chapter
Victor Rentea
 
Spring Boot
Jiayun Zhou
 
Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010
Atlassian
 
Coding standard and coding guideline
Dhananjaysinh Jhala
 
Testing Angular
Lilia Sfaxi
 
Software Quality
Ronald Harmsen
 
Software development best practices & coding guidelines
Ankur Goyal
 
Clean code and Code Smells
Mario Sangiorgio
 
BDD WITH CUCUMBER AND JAVA
Srinivas Katakam
 
Test Driven Development (TDD)
David Ehringer
 
Ad

Similar to Code Review Best Practices (20)

PDF
Code Review Matters and Manners
Trisha Gee
 
PDF
How to get the most out of code reviews
JavaDayUA
 
PDF
Code reviews
Raúl Araya Tauler
 
PPTX
Code Review to the Rescue
Andrei Sviridov
 
PPTX
Code Reviews
phildenoncourt
 
PPTX
Effective Code Review
Eyal Kenig
 
PDF
Code Reviews @ Quatico
Jan Wloka
 
PDF
Code-Review-Principles-Process-and-Tools (1)
Aditya Bhuyan
 
PDF
Code Reviews Inside Out
Ines Jelovac
 
PPT
Code Review
rantav
 
PDF
Voxxed days 2015-hakansaglam-codereview
Hakan Saglam
 
PPT
Introduction to Software Review
Philip Johnson
 
PPTX
Capability Building for Cyber Defense: Software Walk through and Screening
Maven Logix
 
PPTX
Expert Code Review best practices
jeetendra mandal
 
PPTX
Code_Review_Presentation_v22222_LLM.pptx
SofienBoutaib
 
PDF
Effective Peer Review
Joel Hooks
 
PPT
Code reviews: a short introduction
FreekDB
 
PPTX
How to successfully grow a code review culture
Danylenko Max
 
PDF
Code reviews
Juan Maiz
 
PDF
code_review_checklist_6_actions_to_improve_the_quality_of_your_reviews.pdf
sarah david
 
Code Review Matters and Manners
Trisha Gee
 
How to get the most out of code reviews
JavaDayUA
 
Code reviews
Raúl Araya Tauler
 
Code Review to the Rescue
Andrei Sviridov
 
Code Reviews
phildenoncourt
 
Effective Code Review
Eyal Kenig
 
Code Reviews @ Quatico
Jan Wloka
 
Code-Review-Principles-Process-and-Tools (1)
Aditya Bhuyan
 
Code Reviews Inside Out
Ines Jelovac
 
Code Review
rantav
 
Voxxed days 2015-hakansaglam-codereview
Hakan Saglam
 
Introduction to Software Review
Philip Johnson
 
Capability Building for Cyber Defense: Software Walk through and Screening
Maven Logix
 
Expert Code Review best practices
jeetendra mandal
 
Code_Review_Presentation_v22222_LLM.pptx
SofienBoutaib
 
Effective Peer Review
Joel Hooks
 
Code reviews: a short introduction
FreekDB
 
How to successfully grow a code review culture
Danylenko Max
 
Code reviews
Juan Maiz
 
code_review_checklist_6_actions_to_improve_the_quality_of_your_reviews.pdf
sarah david
 
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
 

Recently uploaded (20)

PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PDF
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
PDF
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
PDF
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
PPTX
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 

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?