SlideShare une entreprise Scribd logo
1  sur  24
THE ART OF GIVING AND
RECEIVING CODE REVIEWS
Alex Hill (Imperial College London)
alex.hill@gmail.com
@alexhillphd
Defect finding
● In a software-maintenance organization, 55% of
one-line maintenance changes were in error
before code reviews were introduced. After
reviews were introduced, only 2% of the changes
were in error.
● In a group of 11 programs developed by the same
group of people, the first 5 were developed
without reviews. The remaining 6 were developed
with reviews. After all the programs were released
to production, the first 5 had an average of 4.5
errors per 100 lines of code. The 6 that had been
inspected had an average of only 0.82 errors per
100. Reviews cut the errors by over 80%.
● A study of an organization at AT&T with more than
200 people reported a 90% decrease in defects
after the organization introduced reviews.
Further motivation
1. Learning opportunities
2. Future proofing:
● Increase your bus factor
● Increase your Hawaii factor
● Ensure code is readable
● Maintain code standards
Increase your bus factor
Review < 400 lines of code at a time
Defect density = number of defects found per
1000 lines of code.
Source: Cisco review study, https://www.ibm.com/developerworks/rational/library/11-proven-
practices-for-peer-review/
Review < 500 lines of code per hour
Source: Cisco review study, https://www.ibm.com/developerworks/rational/library/11-proven-
practices-for-peer-review/
Defect density = number of defects found per
1000 lines of code.
Use checklists
Are there unit tests?
Does it follow SOLID principles?
Do you understand it?
Are there integration tests?
Use checklists
Code reviews as dialogue
Source: https://m.xkcd.com/1833/
Understanding defensiveness
http://ragegenerator.com/pages/comic/sql-code-reviews
Minimising unneccessary conflict
● Have clear code conventions
● Automate wherever possible:
– Use a linter
– Unit tests
– Continuous integration
● Author reviews first
Conflict resolution styles
Lower defensiveness
Raise ego
As an organisation we can...
● Pair program
● Discuss tasks prior to implementation
● Never silo codebases
● Emphasize teamwork
● Evaluate the code, not the coder
● Use ‘we’ instead of ‘you’
e.g. “You should have re-used this function” →“We could re-use this function”
● Say ‘thank you’
● Raise code by a grade or 2, no more
e.g. C → B+, B → A
● Ask questions
e.g. “We could re-use this function” → “Could we re-use this function?”
● Justify requests
e.g. “Rename this to `getReportsWithFormattedDate`” → “Could we rename
`getReports` to `getReportsWithFormattedDate`, to make it clear that the
dates will already be formatted when it returns?”
As a reviewer we can...
Give positive feedback!
• “This is a cool library you found”
• “This refactor makes a lot of sense”
• “This is really easy to read”
• “I didn’t know this function existed,
thanks for bringing it to my
attention!”
Source:
http://geekandpoke.typepad.com/geekandpoke/
2010/11/how-to-make-a-good-code-review.html
As an author we can...
● Practice the ‘as if’ technique
– How would I respond if I were grateful for the
feedback?
– How would I respond if I were <Role model>?
– How would I respond if this code was not mine?
● Say ‘thank you’
● Annotate your review first
● Solicit feedback with specific questions
● Optimise reviewer effectiveness
● Minimise unneccessary conflict
● Understand feelings of ownership
● Nudge towards collaboration
● Be nice to each other
Summary

Contenu connexe

Tendances

Visualization, storage and comparison results of performance testing by using...
Visualization, storage and comparison results of performance testing by using...Visualization, storage and comparison results of performance testing by using...
Visualization, storage and comparison results of performance testing by using...Anton Shapin
 
An Introduction To Software Development - Final Review
An Introduction To Software Development - Final ReviewAn Introduction To Software Development - Final Review
An Introduction To Software Development - Final ReviewBlue Elephant Consulting
 
From manual to automation
From manual to automationFrom manual to automation
From manual to automationAnton Shapin
 
How to get reviewers to block your changes
How to get reviewers to block your changesHow to get reviewers to block your changes
How to get reviewers to block your changeskevintbenton
 
Javascript interview questions and answers
Javascript interview questions and answersJavascript interview questions and answers
Javascript interview questions and answersFeedGoCode
 
Unit Testing in Action - C#, NUnit, and Moq
Unit Testing in Action - C#, NUnit, and MoqUnit Testing in Action - C#, NUnit, and Moq
Unit Testing in Action - C#, NUnit, and MoqXPDays
 
Useful practices of creation automatic tests by using cucumber jvm
Useful practices of creation automatic tests by using cucumber jvmUseful practices of creation automatic tests by using cucumber jvm
Useful practices of creation automatic tests by using cucumber jvmAnton Shapin
 
Developer + tester = quality++
Developer + tester = quality++Developer + tester = quality++
Developer + tester = quality++Mikalai Alimenkou
 
Writing Testable Code
Writing Testable CodeWriting Testable Code
Writing Testable Codejameshalsall
 
Win at life with unit testing
Win at life with unit testingWin at life with unit testing
Win at life with unit testingmarkstory
 
API Testing: Answers to Your Top 3 Questions
API Testing: Answers to Your Top 3 QuestionsAPI Testing: Answers to Your Top 3 Questions
API Testing: Answers to Your Top 3 QuestionsQASource
 
Making a Mock by Kelsey Shannahan
Making a Mock by Kelsey ShannahanMaking a Mock by Kelsey Shannahan
Making a Mock by Kelsey ShannahanQA or the Highway
 
Diffy : Automatic Testing of Microservices @ Twitter
Diffy : Automatic Testing of Microservices @ TwitterDiffy : Automatic Testing of Microservices @ Twitter
Diffy : Automatic Testing of Microservices @ TwitterPuneet Khanduri
 
Performance Metrics for your Delivery Pipeline - Wolfgang Gottesheim
Performance Metrics for your Delivery Pipeline - Wolfgang GottesheimPerformance Metrics for your Delivery Pipeline - Wolfgang Gottesheim
Performance Metrics for your Delivery Pipeline - Wolfgang GottesheimJAXLondon2014
 
Avoiding test hell
Avoiding test hellAvoiding test hell
Avoiding test hellYun Ki Lee
 

Tendances (20)

Visualization, storage and comparison results of performance testing by using...
Visualization, storage and comparison results of performance testing by using...Visualization, storage and comparison results of performance testing by using...
Visualization, storage and comparison results of performance testing by using...
 
An Introduction To Software Development - Final Review
An Introduction To Software Development - Final ReviewAn Introduction To Software Development - Final Review
An Introduction To Software Development - Final Review
 
From manual to automation
From manual to automationFrom manual to automation
From manual to automation
 
How to get reviewers to block your changes
How to get reviewers to block your changesHow to get reviewers to block your changes
How to get reviewers to block your changes
 
Api testing
Api testingApi testing
Api testing
 
Javascript interview questions and answers
Javascript interview questions and answersJavascript interview questions and answers
Javascript interview questions and answers
 
TDD Basics with Angular.js and Jasmine
TDD Basics with Angular.js and JasmineTDD Basics with Angular.js and Jasmine
TDD Basics with Angular.js and Jasmine
 
Unit Testing in Action - C#, NUnit, and Moq
Unit Testing in Action - C#, NUnit, and MoqUnit Testing in Action - C#, NUnit, and Moq
Unit Testing in Action - C#, NUnit, and Moq
 
BDD for APIs
BDD for APIsBDD for APIs
BDD for APIs
 
Useful practices of creation automatic tests by using cucumber jvm
Useful practices of creation automatic tests by using cucumber jvmUseful practices of creation automatic tests by using cucumber jvm
Useful practices of creation automatic tests by using cucumber jvm
 
Developer + tester = quality++
Developer + tester = quality++Developer + tester = quality++
Developer + tester = quality++
 
Writing Testable Code
Writing Testable CodeWriting Testable Code
Writing Testable Code
 
API Testing
API TestingAPI Testing
API Testing
 
Win at life with unit testing
Win at life with unit testingWin at life with unit testing
Win at life with unit testing
 
API Testing: Answers to Your Top 3 Questions
API Testing: Answers to Your Top 3 QuestionsAPI Testing: Answers to Your Top 3 Questions
API Testing: Answers to Your Top 3 Questions
 
Making a Mock by Kelsey Shannahan
Making a Mock by Kelsey ShannahanMaking a Mock by Kelsey Shannahan
Making a Mock by Kelsey Shannahan
 
Agile Testing
Agile TestingAgile Testing
Agile Testing
 
Diffy : Automatic Testing of Microservices @ Twitter
Diffy : Automatic Testing of Microservices @ TwitterDiffy : Automatic Testing of Microservices @ Twitter
Diffy : Automatic Testing of Microservices @ Twitter
 
Performance Metrics for your Delivery Pipeline - Wolfgang Gottesheim
Performance Metrics for your Delivery Pipeline - Wolfgang GottesheimPerformance Metrics for your Delivery Pipeline - Wolfgang Gottesheim
Performance Metrics for your Delivery Pipeline - Wolfgang Gottesheim
 
Avoiding test hell
Avoiding test hellAvoiding test hell
Avoiding test hell
 

Similaire à The Art of Giving and Receiving Code Reviews

presentation.pdf
presentation.pdfpresentation.pdf
presentation.pdfcaa28steve
 
Best Practices in Software Development
Best Practices in Software DevelopmentBest Practices in Software Development
Best Practices in Software DevelopmentAndré Pitombeira
 
Let's review it: What designers can learn from (code) review
Let's review it: What designers can learn from (code) reviewLet's review it: What designers can learn from (code) review
Let's review it: What designers can learn from (code) reviewIda Aalen
 
Agile_SDLC_Node.js@Paypal_ppt
Agile_SDLC_Node.js@Paypal_pptAgile_SDLC_Node.js@Paypal_ppt
Agile_SDLC_Node.js@Paypal_pptHitesh Kumar
 
Agile Development | Agile Process Models
Agile Development | Agile Process ModelsAgile Development | Agile Process Models
Agile Development | Agile Process ModelsAhsan Rahim
 
Software Defect Prevention via Continuous Inspection
Software Defect Prevention via Continuous InspectionSoftware Defect Prevention via Continuous Inspection
Software Defect Prevention via Continuous InspectionJosh Gough
 
An Introduction To Software Development - Implementation
An Introduction To Software Development - ImplementationAn Introduction To Software Development - Implementation
An Introduction To Software Development - ImplementationBlue Elephant Consulting
 
Backward thinking design qa system for quality goals
Backward thinking   design qa system for quality goalsBackward thinking   design qa system for quality goals
Backward thinking design qa system for quality goalsgaoliang641
 
Agile testingandautomation
Agile testingandautomationAgile testingandautomation
Agile testingandautomationjeisner
 
Indy meetup#7 effective unit-testing-mule
Indy meetup#7 effective unit-testing-muleIndy meetup#7 effective unit-testing-mule
Indy meetup#7 effective unit-testing-muleikram_ahamed
 
ODSC East 2020 : Continuous_learning_systems
ODSC East 2020 : Continuous_learning_systemsODSC East 2020 : Continuous_learning_systems
ODSC East 2020 : Continuous_learning_systemsAnuj Gupta
 
5 reasons you'll love to hate Agile Development
5 reasons you'll love to hate Agile Development5 reasons you'll love to hate Agile Development
5 reasons you'll love to hate Agile DevelopmentArin Sime
 
Continuous Learning Systems: Building ML systems that learn from their mistakes
Continuous Learning Systems: Building ML systems that learn from their mistakesContinuous Learning Systems: Building ML systems that learn from their mistakes
Continuous Learning Systems: Building ML systems that learn from their mistakesAnuj Gupta
 
Three Interviews About Static Code Analyzers
Three Interviews About Static Code AnalyzersThree Interviews About Static Code Analyzers
Three Interviews About Static Code AnalyzersAndrey Karpov
 
Preparing for Enterprise Continuous Delivery - 5 Critical Steps
Preparing for Enterprise Continuous Delivery - 5 Critical StepsPreparing for Enterprise Continuous Delivery - 5 Critical Steps
Preparing for Enterprise Continuous Delivery - 5 Critical StepsXebiaLabs
 
Building Continuous Learning Systems
Building Continuous Learning SystemsBuilding Continuous Learning Systems
Building Continuous Learning SystemsAnuj Gupta
 
Quality metrics and angular js applications
Quality metrics and angular js applicationsQuality metrics and angular js applications
Quality metrics and angular js applicationsnadeembtech
 
agility_principles.ppt
agility_principles.pptagility_principles.ppt
agility_principles.pptAteeqaKokab1
 

Similaire à The Art of Giving and Receiving Code Reviews (20)

presentation.pdf
presentation.pdfpresentation.pdf
presentation.pdf
 
Code Reviews
Code ReviewsCode Reviews
Code Reviews
 
Best Practices in Software Development
Best Practices in Software DevelopmentBest Practices in Software Development
Best Practices in Software Development
 
Let's review it: What designers can learn from (code) review
Let's review it: What designers can learn from (code) reviewLet's review it: What designers can learn from (code) review
Let's review it: What designers can learn from (code) review
 
Agile_SDLC_Node.js@Paypal_ppt
Agile_SDLC_Node.js@Paypal_pptAgile_SDLC_Node.js@Paypal_ppt
Agile_SDLC_Node.js@Paypal_ppt
 
Agile Development | Agile Process Models
Agile Development | Agile Process ModelsAgile Development | Agile Process Models
Agile Development | Agile Process Models
 
Software Defect Prevention via Continuous Inspection
Software Defect Prevention via Continuous InspectionSoftware Defect Prevention via Continuous Inspection
Software Defect Prevention via Continuous Inspection
 
An Introduction To Software Development - Implementation
An Introduction To Software Development - ImplementationAn Introduction To Software Development - Implementation
An Introduction To Software Development - Implementation
 
Backward thinking design qa system for quality goals
Backward thinking   design qa system for quality goalsBackward thinking   design qa system for quality goals
Backward thinking design qa system for quality goals
 
Agile testingandautomation
Agile testingandautomationAgile testingandautomation
Agile testingandautomation
 
Indy meetup#7 effective unit-testing-mule
Indy meetup#7 effective unit-testing-muleIndy meetup#7 effective unit-testing-mule
Indy meetup#7 effective unit-testing-mule
 
ODSC East 2020 : Continuous_learning_systems
ODSC East 2020 : Continuous_learning_systemsODSC East 2020 : Continuous_learning_systems
ODSC East 2020 : Continuous_learning_systems
 
5 reasons you'll love to hate Agile Development
5 reasons you'll love to hate Agile Development5 reasons you'll love to hate Agile Development
5 reasons you'll love to hate Agile Development
 
Continuous Learning Systems: Building ML systems that learn from their mistakes
Continuous Learning Systems: Building ML systems that learn from their mistakesContinuous Learning Systems: Building ML systems that learn from their mistakes
Continuous Learning Systems: Building ML systems that learn from their mistakes
 
Three Interviews About Static Code Analyzers
Three Interviews About Static Code AnalyzersThree Interviews About Static Code Analyzers
Three Interviews About Static Code Analyzers
 
Preparing for Enterprise Continuous Delivery - 5 Critical Steps
Preparing for Enterprise Continuous Delivery - 5 Critical StepsPreparing for Enterprise Continuous Delivery - 5 Critical Steps
Preparing for Enterprise Continuous Delivery - 5 Critical Steps
 
Peer review
Peer reviewPeer review
Peer review
 
Building Continuous Learning Systems
Building Continuous Learning SystemsBuilding Continuous Learning Systems
Building Continuous Learning Systems
 
Quality metrics and angular js applications
Quality metrics and angular js applicationsQuality metrics and angular js applications
Quality metrics and angular js applications
 
agility_principles.ppt
agility_principles.pptagility_principles.ppt
agility_principles.ppt
 

Dernier

How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 

Dernier (20)

How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 

The Art of Giving and Receiving Code Reviews

  • 1. THE ART OF GIVING AND RECEIVING CODE REVIEWS Alex Hill (Imperial College London) alex.hill@gmail.com @alexhillphd
  • 2. Defect finding ● In a software-maintenance organization, 55% of one-line maintenance changes were in error before code reviews were introduced. After reviews were introduced, only 2% of the changes were in error. ● In a group of 11 programs developed by the same group of people, the first 5 were developed without reviews. The remaining 6 were developed with reviews. After all the programs were released to production, the first 5 had an average of 4.5 errors per 100 lines of code. The 6 that had been inspected had an average of only 0.82 errors per 100. Reviews cut the errors by over 80%. ● A study of an organization at AT&T with more than 200 people reported a 90% decrease in defects after the organization introduced reviews.
  • 3. Further motivation 1. Learning opportunities 2. Future proofing: ● Increase your bus factor ● Increase your Hawaii factor ● Ensure code is readable ● Maintain code standards Increase your bus factor
  • 4. Review < 400 lines of code at a time Defect density = number of defects found per 1000 lines of code. Source: Cisco review study, https://www.ibm.com/developerworks/rational/library/11-proven- practices-for-peer-review/
  • 5. Review < 500 lines of code per hour Source: Cisco review study, https://www.ibm.com/developerworks/rational/library/11-proven- practices-for-peer-review/ Defect density = number of defects found per 1000 lines of code.
  • 6. Use checklists Are there unit tests? Does it follow SOLID principles? Do you understand it? Are there integration tests?
  • 8. Code reviews as dialogue Source: https://m.xkcd.com/1833/
  • 9.
  • 11.
  • 12.
  • 13.
  • 15.
  • 16.
  • 17. Minimising unneccessary conflict ● Have clear code conventions ● Automate wherever possible: – Use a linter – Unit tests – Continuous integration ● Author reviews first
  • 20. As an organisation we can... ● Pair program ● Discuss tasks prior to implementation ● Never silo codebases ● Emphasize teamwork ● Evaluate the code, not the coder
  • 21. ● Use ‘we’ instead of ‘you’ e.g. “You should have re-used this function” →“We could re-use this function” ● Say ‘thank you’ ● Raise code by a grade or 2, no more e.g. C → B+, B → A ● Ask questions e.g. “We could re-use this function” → “Could we re-use this function?” ● Justify requests e.g. “Rename this to `getReportsWithFormattedDate`” → “Could we rename `getReports` to `getReportsWithFormattedDate`, to make it clear that the dates will already be formatted when it returns?” As a reviewer we can...
  • 22. Give positive feedback! • “This is a cool library you found” • “This refactor makes a lot of sense” • “This is really easy to read” • “I didn’t know this function existed, thanks for bringing it to my attention!” Source: http://geekandpoke.typepad.com/geekandpoke/ 2010/11/how-to-make-a-good-code-review.html
  • 23. As an author we can... ● Practice the ‘as if’ technique – How would I respond if I were grateful for the feedback? – How would I respond if I were <Role model>? – How would I respond if this code was not mine? ● Say ‘thank you’ ● Annotate your review first ● Solicit feedback with specific questions
  • 24. ● Optimise reviewer effectiveness ● Minimise unneccessary conflict ● Understand feelings of ownership ● Nudge towards collaboration ● Be nice to each other Summary