SlideShare a Scribd company logo
1 of 33
Code Reviews
Code Review
• At least three problems?
– You hate being critiqued that way
– You’d much rather write more code in that
time
– Project manager says “last time you guys got
together for review, fight ensued and one guy
quit, no more code reviews for you…”
– Venkat Subramaniam Caring About Code Quality
Assumption
From the Principles behind the Agile
Manifesto
– Build projects around motivated individuals.
Give them the environment and support they need,
and trust them to get the job done.
Why
There are known knowns. These are things
we know that we know. There are known
unknowns. That is to say, there are things
that we know we don't know. But there are
also unknown unknowns. There are things
we don't know we don't know.
--Donald Rumsfeld (February 2002)
Known knowns
– Things that you know that you know
– Code it!
Known unknowns
– Things you know that you don’t know
– Research
– Ask questions (gasp)
Why
Unknown unknowns
– Things you don’t know you don’t know
Discussion
Purpose or Goal of a Peer Code Review
Purpose
1. Does code accomplish task?
2. Catch bugs early
– Those not found in unit testing
3. Find coding inefficiencies
– Remove unnecessary code
– Avoid code smells
4. Share knowledge
– Team Collaboration
– Increased bus factor
5. Meets standards
The buck stops with the code review
process, whereby a change is
accepted for inclusion into the code
base by the developers who control
access to the canonical source
repository. If unit tests are not
required by a code reviewer, then
cruft will pile on top of cruft.
- Martin Fowler Goto Fail, Heartbleed, and Unit Testing Culture
(2014)
Unit Tests!
Methods
Ways to do code reviews
Methods
• Fagan Inspection
– Developed at IBM
– Code Inspection
– Seven phases
– Four Participants
– …
• see http://www.professionalqa.com/fagan-inspection
Just Kidding. Do not do Michael Fagon Method
see http://www.methodsandtools.com/archive/archive.php?id=66
Methods
• Self-Review (you talk to the object)
• Also Called Rubber Duck Debugging
Methods
• Pair Programming
– Continuous Code Review
Discussion
Pull Requests, Pros and Cons
The fear of big merges also acts as a deterrent to
refactoring. Keeping code clean is constant effort,
to do it well it requires everyone to keep an eye out
for cruft and fix it wherever they see it. However
this kind of refactoring on a feature branch is
awkward because it makes the Big Scary Merge
much worse. The result we see is that teams using
feature branches shy away from refactoring which
leads to uglier code bases.
Indeed I see this as the decisive reason why
Feature Branching is a bad idea. Once a team is
afraid to refactor to keep their code healthy they
are on downward spiral with no pretty end.
- Martin Fowler, Feature Branch (2009)
How to
As code author
• Review your own code
• Commit small changes
• Document – self documenting – code
• Provide meaningful commit message
As a reviewer
• Do not postpone
– Our culture requires reviews frequent reviews
• Spent sufficient time
– Can be 10 minutes
– Max 60 to 90 minutes
• Know the requirements
• Add expertise
Discussion
What to look for in a review
Human Factor
Human Factor
You are not your code
So criticism of code should not bother you
Human Factor
• Code represents work
• Work is time and effort
• Changes to code requires more work
– We all have deadlines
• Code represents expertise
– We all are reviewed
Human Factor
Scathing and/or never ending code reviews hurt
Human Factor
• Communicate clearly
– Use constructive phrases
– Give examples/suggestions
• Listen to concerns
• Code review is not a place for coding style
wars
– Decide ahead of time what code style is
– Use linters
The first rule in decision-making
is that one does not make a
decision unless there is
disagreement.
-Peter Drucker The Effective Executive
Tips
Keep it Small
Tips
• Keep pull request to a single idea
• Tie goes to the runner
– The author of the code is responsible for the
final decision
• Move comments from review to inside of
code
– comments explain why, not what
• In teams, use @specific_person for review
where specific_person has expertise
Tips
• Don’t over-do or under-do time on review
• Don’t procrastinate doing review
• “Looks good” is not a code review
Goal
Maximize Productivity and Code Quality
You can’t be agile if your code sucks
- venkat subramaniam
See Atlassian Article
https://www.atlassian.com/agile/software-development/code-reviews

More Related Content

What's hot

Shrinivas kulkarni Testing is Dead
Shrinivas kulkarni   Testing is DeadShrinivas kulkarni   Testing is Dead
Shrinivas kulkarni Testing is DeadvodQA
 
Effective Code Reviews (IPC 2018)
Effective Code Reviews (IPC 2018)Effective Code Reviews (IPC 2018)
Effective Code Reviews (IPC 2018)Frank Sons
 
Agile Network India | Challenges in executing Agile Projects to deliver value...
Agile Network India | Challenges in executing Agile Projects to deliver value...Agile Network India | Challenges in executing Agile Projects to deliver value...
Agile Network India | Challenges in executing Agile Projects to deliver value...AgileNetwork
 
Test-Driven Development (TDD) in Swift
Test-Driven Development (TDD) in SwiftTest-Driven Development (TDD) in Swift
Test-Driven Development (TDD) in SwiftAmey Tavkar
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven DevelopmentSamnang Chhun
 
Mobile Development - Unit and Automation Testing
Mobile Development - Unit and Automation TestingMobile Development - Unit and Automation Testing
Mobile Development - Unit and Automation TestingManuel Vicente Vivo
 
XPDDS19 Keynote: Patch Review for Non-maintainers - George Dunlap, Citrix Sys...
XPDDS19 Keynote: Patch Review for Non-maintainers - George Dunlap, Citrix Sys...XPDDS19 Keynote: Patch Review for Non-maintainers - George Dunlap, Citrix Sys...
XPDDS19 Keynote: Patch Review for Non-maintainers - George Dunlap, Citrix Sys...The Linux Foundation
 
Dev Nexus 2017 - TDD with React - Josh Quintana & Tom Gamble
Dev Nexus 2017 - TDD with React - Josh Quintana & Tom GambleDev Nexus 2017 - TDD with React - Josh Quintana & Tom Gamble
Dev Nexus 2017 - TDD with React - Josh Quintana & Tom GambleThomas Gamble
 
The problem with tdd
The problem with tddThe problem with tdd
The problem with tddDror Helper
 
Community and Github: 7/27/2011
Community and Github: 7/27/2011Community and Github: 7/27/2011
Community and Github: 7/27/2011Andy Lester
 
Agile Testers: Becoming a key asset for your team
Agile Testers: Becoming a key asset for your teamAgile Testers: Becoming a key asset for your team
Agile Testers: Becoming a key asset for your teamgojkoadzic
 

What's hot (17)

Shrinivas kulkarni Testing is Dead
Shrinivas kulkarni   Testing is DeadShrinivas kulkarni   Testing is Dead
Shrinivas kulkarni Testing is Dead
 
Effective Code Reviews (IPC 2018)
Effective Code Reviews (IPC 2018)Effective Code Reviews (IPC 2018)
Effective Code Reviews (IPC 2018)
 
Agile Network India | Challenges in executing Agile Projects to deliver value...
Agile Network India | Challenges in executing Agile Projects to deliver value...Agile Network India | Challenges in executing Agile Projects to deliver value...
Agile Network India | Challenges in executing Agile Projects to deliver value...
 
Test-Driven Development (TDD) in Swift
Test-Driven Development (TDD) in SwiftTest-Driven Development (TDD) in Swift
Test-Driven Development (TDD) in Swift
 
Tdd in swift
Tdd in swiftTdd in swift
Tdd in swift
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
A Rapid e-Learning Primer for Technical Communicators
A Rapid e-Learning Primer for Technical CommunicatorsA Rapid e-Learning Primer for Technical Communicators
A Rapid e-Learning Primer for Technical Communicators
 
Testing 101: Three Rules for Testing at Ombu Labs
Testing 101: Three Rules for Testing at Ombu Labs Testing 101: Three Rules for Testing at Ombu Labs
Testing 101: Three Rules for Testing at Ombu Labs
 
Mobile Development - Unit and Automation Testing
Mobile Development - Unit and Automation TestingMobile Development - Unit and Automation Testing
Mobile Development - Unit and Automation Testing
 
Pragmatic 1
Pragmatic 1Pragmatic 1
Pragmatic 1
 
Introduction to TDD
Introduction to TDDIntroduction to TDD
Introduction to TDD
 
XPDDS19 Keynote: Patch Review for Non-maintainers - George Dunlap, Citrix Sys...
XPDDS19 Keynote: Patch Review for Non-maintainers - George Dunlap, Citrix Sys...XPDDS19 Keynote: Patch Review for Non-maintainers - George Dunlap, Citrix Sys...
XPDDS19 Keynote: Patch Review for Non-maintainers - George Dunlap, Citrix Sys...
 
Dev Nexus 2017 - TDD with React - Josh Quintana & Tom Gamble
Dev Nexus 2017 - TDD with React - Josh Quintana & Tom GambleDev Nexus 2017 - TDD with React - Josh Quintana & Tom Gamble
Dev Nexus 2017 - TDD with React - Josh Quintana & Tom Gamble
 
The problem with tdd
The problem with tddThe problem with tdd
The problem with tdd
 
Community and Github: 7/27/2011
Community and Github: 7/27/2011Community and Github: 7/27/2011
Community and Github: 7/27/2011
 
James thomas
James thomasJames thomas
James thomas
 
Agile Testers: Becoming a key asset for your team
Agile Testers: Becoming a key asset for your teamAgile Testers: Becoming a key asset for your team
Agile Testers: Becoming a key asset for your team
 

Similar to Code reviews

Code review guidelines
Code review guidelinesCode review guidelines
Code review guidelinesLalit Kale
 
10 Faulty Behaviors of Code Review - Developer Summit Istanbul 2018
10 Faulty Behaviors of Code Review - Developer Summit Istanbul 201810 Faulty Behaviors of Code Review - Developer Summit Istanbul 2018
10 Faulty Behaviors of Code Review - Developer Summit Istanbul 2018Lemi Orhan Ergin
 
Code Review Best Practices
Code Review Best PracticesCode Review Best Practices
Code Review Best PracticesTrisha Gee
 
A Brief Introduction to Test-Driven Development
A Brief Introduction to Test-Driven DevelopmentA Brief Introduction to Test-Driven Development
A Brief Introduction to Test-Driven DevelopmentShawn Jones
 
How to successfully grow a code review culture
How to successfully grow a code review cultureHow to successfully grow a code review culture
How to successfully grow a code review cultureNina Zakharenko
 
Recruiting the right people quickly public
Recruiting the right people quickly   publicRecruiting the right people quickly   public
Recruiting the right people quickly publicAshley Frieze
 
Scaling your code review
Scaling your code reviewScaling your code review
Scaling your code reviewSander Bol
 
Surviving the technical interview
Surviving the technical interviewSurviving the technical interview
Surviving the technical interviewEric Brooke
 
Creating change from within - Agile Practitioners 2012
Creating change from within - Agile Practitioners 2012Creating change from within - Agile Practitioners 2012
Creating change from within - Agile Practitioners 2012Dror Helper
 
Code reviews: a short introduction
Code reviews: a short introductionCode reviews: a short introduction
Code reviews: a short introductionFreekDB
 
Introducing Pair Programming
Introducing Pair ProgrammingIntroducing Pair Programming
Introducing Pair ProgrammingSteven Smith
 
I Don't Code, Am I No Longer Useful
I Don't Code, Am I No Longer UsefulI Don't Code, Am I No Longer Useful
I Don't Code, Am I No Longer UsefulMaaret Pyhäjärvi
 
Arch factory - Agile Design: Best Practices
Arch factory - Agile Design: Best PracticesArch factory - Agile Design: Best Practices
Arch factory - Agile Design: Best PracticesIgor Moochnick
 
Greythorn Whiteboard Interview Guide
Greythorn Whiteboard Interview GuideGreythorn Whiteboard Interview Guide
Greythorn Whiteboard Interview GuideVaco Seattle
 
Extreme Programming (XP): Revisted
Extreme Programming (XP): RevistedExtreme Programming (XP): Revisted
Extreme Programming (XP): RevistedMike Harris
 
Discussing Design: The Art of Critique
Discussing Design: The Art of CritiqueDiscussing Design: The Art of Critique
Discussing Design: The Art of CritiqueAaron Irizarry
 

Similar to Code reviews (20)

Code review guidelines
Code review guidelinesCode review guidelines
Code review guidelines
 
10 Faulty Behaviors of Code Review - Developer Summit Istanbul 2018
10 Faulty Behaviors of Code Review - Developer Summit Istanbul 201810 Faulty Behaviors of Code Review - Developer Summit Istanbul 2018
10 Faulty Behaviors of Code Review - Developer Summit Istanbul 2018
 
Code Review Best Practices
Code Review Best PracticesCode Review Best Practices
Code Review Best Practices
 
A Brief Introduction to Test-Driven Development
A Brief Introduction to Test-Driven DevelopmentA Brief Introduction to Test-Driven Development
A Brief Introduction to Test-Driven Development
 
Peer review
Peer reviewPeer review
Peer review
 
How to successfully grow a code review culture
How to successfully grow a code review cultureHow to successfully grow a code review culture
How to successfully grow a code review culture
 
Recruiting the right people quickly public
Recruiting the right people quickly   publicRecruiting the right people quickly   public
Recruiting the right people quickly public
 
Scaling your code review
Scaling your code reviewScaling your code review
Scaling your code review
 
Code review
Code reviewCode review
Code review
 
Surviving the technical interview
Surviving the technical interviewSurviving the technical interview
Surviving the technical interview
 
Creating change from within - Agile Practitioners 2012
Creating change from within - Agile Practitioners 2012Creating change from within - Agile Practitioners 2012
Creating change from within - Agile Practitioners 2012
 
Code reviews: a short introduction
Code reviews: a short introductionCode reviews: a short introduction
Code reviews: a short introduction
 
Introducing Pair Programming
Introducing Pair ProgrammingIntroducing Pair Programming
Introducing Pair Programming
 
I Don't Code, Am I No Longer Useful
I Don't Code, Am I No Longer UsefulI Don't Code, Am I No Longer Useful
I Don't Code, Am I No Longer Useful
 
Arch factory - Agile Design: Best Practices
Arch factory - Agile Design: Best PracticesArch factory - Agile Design: Best Practices
Arch factory - Agile Design: Best Practices
 
Intro to TDD
Intro to TDDIntro to TDD
Intro to TDD
 
Greythorn Whiteboard Interview Guide
Greythorn Whiteboard Interview GuideGreythorn Whiteboard Interview Guide
Greythorn Whiteboard Interview Guide
 
Extreme Programming (XP): Revisted
Extreme Programming (XP): RevistedExtreme Programming (XP): Revisted
Extreme Programming (XP): Revisted
 
Tdd
TddTdd
Tdd
 
Discussing Design: The Art of Critique
Discussing Design: The Art of CritiqueDiscussing Design: The Art of Critique
Discussing Design: The Art of Critique
 

Recently uploaded

What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 

Recently uploaded (20)

What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 

Code reviews

  • 2. Code Review • At least three problems? – You hate being critiqued that way – You’d much rather write more code in that time – Project manager says “last time you guys got together for review, fight ensued and one guy quit, no more code reviews for you…” – Venkat Subramaniam Caring About Code Quality
  • 3. Assumption From the Principles behind the Agile Manifesto – Build projects around motivated individuals. Give them the environment and support they need, and trust them to get the job done.
  • 4. Why There are known knowns. These are things we know that we know. There are known unknowns. That is to say, there are things that we know we don't know. But there are also unknown unknowns. There are things we don't know we don't know. --Donald Rumsfeld (February 2002)
  • 5. Known knowns – Things that you know that you know – Code it!
  • 6. Known unknowns – Things you know that you don’t know – Research – Ask questions (gasp)
  • 7. Why Unknown unknowns – Things you don’t know you don’t know
  • 8. Discussion Purpose or Goal of a Peer Code Review
  • 9. Purpose 1. Does code accomplish task? 2. Catch bugs early – Those not found in unit testing 3. Find coding inefficiencies – Remove unnecessary code – Avoid code smells 4. Share knowledge – Team Collaboration – Increased bus factor 5. Meets standards
  • 10. The buck stops with the code review process, whereby a change is accepted for inclusion into the code base by the developers who control access to the canonical source repository. If unit tests are not required by a code reviewer, then cruft will pile on top of cruft. - Martin Fowler Goto Fail, Heartbleed, and Unit Testing Culture (2014) Unit Tests!
  • 11. Methods Ways to do code reviews
  • 12. Methods • Fagan Inspection – Developed at IBM – Code Inspection – Seven phases – Four Participants – … • see http://www.professionalqa.com/fagan-inspection
  • 13. Just Kidding. Do not do Michael Fagon Method see http://www.methodsandtools.com/archive/archive.php?id=66
  • 14. Methods • Self-Review (you talk to the object) • Also Called Rubber Duck Debugging
  • 15. Methods • Pair Programming – Continuous Code Review
  • 17. The fear of big merges also acts as a deterrent to refactoring. Keeping code clean is constant effort, to do it well it requires everyone to keep an eye out for cruft and fix it wherever they see it. However this kind of refactoring on a feature branch is awkward because it makes the Big Scary Merge much worse. The result we see is that teams using feature branches shy away from refactoring which leads to uglier code bases. Indeed I see this as the decisive reason why Feature Branching is a bad idea. Once a team is afraid to refactor to keep their code healthy they are on downward spiral with no pretty end. - Martin Fowler, Feature Branch (2009)
  • 19. As code author • Review your own code • Commit small changes • Document – self documenting – code • Provide meaningful commit message
  • 20. As a reviewer • Do not postpone – Our culture requires reviews frequent reviews • Spent sufficient time – Can be 10 minutes – Max 60 to 90 minutes • Know the requirements • Add expertise
  • 21. Discussion What to look for in a review
  • 23. Human Factor You are not your code So criticism of code should not bother you
  • 24. Human Factor • Code represents work • Work is time and effort • Changes to code requires more work – We all have deadlines • Code represents expertise – We all are reviewed
  • 25. Human Factor Scathing and/or never ending code reviews hurt
  • 26. Human Factor • Communicate clearly – Use constructive phrases – Give examples/suggestions • Listen to concerns • Code review is not a place for coding style wars – Decide ahead of time what code style is – Use linters
  • 27. The first rule in decision-making is that one does not make a decision unless there is disagreement. -Peter Drucker The Effective Executive
  • 28. Tips
  • 30. Tips • Keep pull request to a single idea • Tie goes to the runner – The author of the code is responsible for the final decision • Move comments from review to inside of code – comments explain why, not what • In teams, use @specific_person for review where specific_person has expertise
  • 31. Tips • Don’t over-do or under-do time on review • Don’t procrastinate doing review • “Looks good” is not a code review
  • 32. Goal Maximize Productivity and Code Quality You can’t be agile if your code sucks - venkat subramaniam