SlideShare a Scribd company logo
1 of 30
Download to read offline
Effective
Code Reviews
William Deurwaarder
30th of May, 2015
NextBuild
Think profit-based, not cost-based.
TomTom devices
2
Think profit-based, not cost-based.
TomTom products
Maps
Navigation
Traffic
Fleet-management
Fitness
3
Think profit-based, not cost-based.
Introduction
• Theory
• Creates awareness, explains philosophy
• Defines “defect” and explains its impact
• Practice
• How to improve the efficiency of reviews?
• What is role and mindset of author and reviewer?
• How to execute reviews?
Think profit-based, not cost-based.
Perfect code
What is perfect code?
• Working
• Readable
• Maintainable
• Extendable
• Elegant
• Simple and clear
• Well documented
• …
Easy to recognize, hard to describe
Think profit-based, not cost-based.
Not so perfect code
Why is real code not so perfect?
• Time-boxed
• Lack of experience
• Change on change
• Edge cases
• Built on legacy
• Mindset author (problem solving, result oriented, pragmatic, …)
• Multiple authors (own mind, no machines)
Easy to describe, hard to fight
Think profit-based, not cost-based.
Definition of defect
What is a defect?
• Highly unlikely defects
• Race conditions
• Timing issues
• Extreme load
• Trivial defects
• Subjective term
• Hard to predict impact of a defect
Defect: anything that may cause any additional cost later on
Think profit-based, not cost-based.
Cost of defects
Cost to fix defect grows exponentially
Consider 4 stages: design  develop  test  production
Every stage adds additional cost factor of 10
• code review instead of test: 10x cost savings
• code review in stead of production: 100x cost savings
Finding/fixing defects early is always faster and
cheaper than not finding or not fixing them
Think profit-based, not cost-based.
Cost of defects
1 single defect will pay for 100
99 defects never ever causes a problem
1 single defect causes a problem in production
Question is: which one?
No significant additional cost fixing 5 or 50 defects
Building, Reviewing, Testing, Deploying
Fix ALL defects that you can find (no priorities)
Think profit-based, not cost-based.
Fix ALL defects
What happens next?
• No trivial defects any more
• No discussion on minor and major, just defect
• No subjective reasoning
Cleaner and more useful statistics as well
• Code gets higher quality and is easier to review
Increased developer pride, reduced ‘broken window’ effect
Think profit-based, not cost-based.
Change your thinking!
The cost of fixing everything is small,
and the profit is much higher than the cost
Fix all defects that are found
• Ensure defects that cause issues are fixed
• Ensure defect that pays for all other defects is fixed
Think profit-based, not cost-based
Think profit-based, not cost-based.
Statistics
This is about applied statistics
Good engineers respect statistics
You are an engineer… respect and obey statistics!
Know: Many defects will never cause an issue if left unfixed
So: Fixing an individual defect does not necessarily reduce cost
And: Some (unlikely) defects will lead to great cost if left unfixed
But: You cannot tell which defect will cause an issue
Not about individual defects or reviews, about applying this
practice continuously -> benefits
Think profit-based, not cost-based.
Theory summary
Defects enter our code for a lot of reasons
Defect is anything that cause additional costs
Cost to fix defect grows exponentially
Fix ALL defects
Think profit-based
It is all about statistics
Effective
Code Reviews
(Practice)
William Deurwaarder
30th of May, 2015
Think profit-based, not cost-based.
Introduction
• Theory (previous session)
• Creates awareness, explains philosophy
• Defines “defect” and explains its impact
• Practice
• How to improve the efficiency of reviews?
• What is role and mindset of author and reviewer?
• How to execute reviews?
Think profit-based, not cost-based.
Improve quality
How can reviews address mentioned issues?
• Reviewer has different goal so different mindset
• Author solves the problem
• Reviewer checks code quality (guardian)
• Solution fits context
• Solution adheres to good practices
• Reviewer is not bothered by time (dead-line)
• Reviewer looks at code from different angle
Code review is an easy tool to increase quality
Think profit-based, not cost-based.
Increase efficiency of reviews
What can be changed to become effective?
• A: Ensure changes are ready (static code analysis, annotate)
• A: Limit number of reviewers (default is 2)
• R: Find as many defects as possible (time-boxed)
• R: Be thorough (address everything that catches the eye)
• Sharing knowledge
• Establish team-culture (abbreviations, code duplication)
• A: Fix ALL defects (no priorities)
• R+A: work together, same goal (peers)
• No need to defend yourself: “finding more defects is better”
Think profit-based, not cost-based.
Role and mindset author
Problem solver – solution driven – time aware
• Prepare review (static code analysis, review yourself, annotate)
• Remarks aim to increase quality of code
• not to discuss author’s ability to code (no defense)
• Normally answer questions with comment in code
• Review will almost never be read again, code will
• Address ALL found defects (no priorities)
• minor defects take very little time to fix (no discussion required)
• Handle clearly incorrect remarks respectfully
• Discuss off-line; comment in code?
• Author is end responsible for changes and quality
Think profit-based, not cost-based.
Role and mindset reviewer
Guardian – quality driven – time-boxed
• Execute review promptly (do not become a bottleneck)
• Make only remarks to improve quality of code
• Do not offer solutions or “better alternatives”
• Do not “educate” the author (off-line, coaching)
• Thorough, relentless AND respectful
• Can never find too many defects (slow pace)
• Avoid religious wars, no personal flavors, only technical
• Explain why something needs improvement
• Ignore amount of rework to fix defect
• Always re-review after author updated code (prompt)
Think profit-based, not cost-based.
Tone of review
• Be neutral, explain your interpretation
• Be aware of different mindset
• Be respectful (no SHOUTING!, no telling, no lecture, use keywords)
• Explain with reasoning in case technical solution needs
improvement
• Single problem may have multiple solutions
• Search for reasons of unclarity (do not ask why to quickly)
Remember goal
• author is responsible for code quality
• reviewer helps author to establish level of quality
• working together as peers to improve quality
Think profit-based, not cost-based.
Examples
- What is this about?
+ The context is unclear, can you explain…
- This sucks…
+ This causes issues like x, y, z…
- Did you read the documentation at all?
+ The documentation specifies x rather than doing y…
- You should implement this completely different!
+ Doing x causes issues y and z in…
- NO, NO, NO…
+ This causes issues x, y, z in…
Think profit-based, not cost-based.
Defect remark strategy
• Gather context information (design, user-story, JIRA-issue)
• Focus on changes, keep eye on context
• Search for patterns and inconsistencies
• Check complexity (bang-for-buck, keep-it-simple-stupid)
• Let unconscious mind help (bell ringing -> investigate)
• Act like logical compiler (do not interpret code -> read code)
• Ask if something is unclear (comment should be added)
• Mark all style defects (diminishes quickly, static code analysis)
• Code removal – check correct and complete
• Use checklists
Think profit-based, not cost-based.
Practice summary
Author is responsible for code quality
Reviewer helps author to establish level of quality
Author and reviewer work together as peers
Reviewer is thorough, relentless and prompt
Author fixes all found defects
Reviewer review all changesBe polite
Think profit-based, not cost-based.
Code review rules
Time-boxed period to polish the code
Thank you
Any questions?
William Deurwaarder
Head of Developer Relations, TomTom
E-mail: william.deurwaarder@tomtom.com
Website: http://developer.tomtom.com
Think profit-based, not cost-based.
Code-review figures
Indication of important figures
• Minimum review time per session 5 minutes
• Maximum review time per session 60 – 90 minutes
• Maximum review size per session 200 – 400 LOC
• Default number of reviewers 2
• Maximum inspection rate 300 – 500 LOC / hour
Think profit-based, not cost-based.
Checklist for code-review (1/4)
Check consistency with design (see change in bigger scope)
• Verify edge-cases
Check consistency interface changes
• Scope changed (private to public; why?)
• Order of parameters (same in all methods)
• Symmetrical methods
• Use of default parameters
• Implementation details leak through in interface
Check level of containment (increasingly risky, increase scope)
• Within method
• Within private methods
• Within public class methods
• Within public interface of system (NavKit)
Think profit-based, not cost-based.
Checklist for code-review (2/4)
Check complexity
• Keep algorithms clean (no exceptional cases)
• Verify edge-cases… throw exception in stead?
• Try what-if scenarios
Check exception handling
• Is exception caught?
• Adheres to exception handling policy
• Exception handling aligned with surrounding code
Check readability, clarity (decrease time to understand code)
• Remove code duplication (extract method)
• Check functionality of method (reduce size of method)
• Add comments to increase readability
Think profit-based, not cost-based.
Checklist for code-review (3/4)
Check includes/imports (needed? correct?)
Check NULL-pointer behavior (can reference be used?)
Check const-behavior (consistent, no const_cast)
Check algorithms for one-off errors
Check resource leakage (memory, file handles, …)
Check multi-threading behavior
• Race-conditions
• Dead-lock situations
Check usage of members and local variables
• No state duplication (only for measured performance improvement)
• Superfluous
• No re-use of variables with different meaning
Think profit-based, not cost-based.
Checklist for code-review (4/4)
Check type-casts (discourage them)
Check surrounding comments
Check correct usage of libraries (STL, OSAL, …)
Check “early” optimization
• Is measurement in place?
• Is there comment with explanation?
Check use of deprecated code
• NavKit-examples: NavKitEnvironment, Tdes, CString
Check use of discouraged patterns
• Singleton
Check if tests exists

More Related Content

What's hot

Agile Talk 30 Jul 1o2
Agile Talk 30 Jul 1o2Agile Talk 30 Jul 1o2
Agile Talk 30 Jul 1o2Akhil Kumar
 
Going extreme-with-extreme-programming
Going extreme-with-extreme-programmingGoing extreme-with-extreme-programming
Going extreme-with-extreme-programmingMichael Green
 
It's XP Stupid (2019)
It's XP Stupid (2019)It's XP Stupid (2019)
It's XP Stupid (2019)Mike Harris
 
Agile Practices - eXtreme Programming
Agile Practices - eXtreme ProgrammingAgile Practices - eXtreme Programming
Agile Practices - eXtreme ProgrammingAniruddha Chakrabarti
 
Twelve practices of XP_Se lect5 btech
Twelve practices of XP_Se lect5 btechTwelve practices of XP_Se lect5 btech
Twelve practices of XP_Se lect5 btechIIITA
 
Advancing Testing Using Axioms
Advancing Testing Using AxiomsAdvancing Testing Using Axioms
Advancing Testing Using AxiomsSQALab
 
Audrys Kažukauskas - Introduction into Extreme Programming
Audrys Kažukauskas - Introduction into Extreme ProgrammingAudrys Kažukauskas - Introduction into Extreme Programming
Audrys Kažukauskas - Introduction into Extreme ProgrammingAgile Lietuva
 
eXtreme programming (XP) - An Overview
eXtreme programming (XP) - An OvervieweXtreme programming (XP) - An Overview
eXtreme programming (XP) - An OverviewGurtej Pal Singh
 
optimizing code in compilers using parallel genetic algorithm
optimizing code in compilers using parallel genetic algorithm optimizing code in compilers using parallel genetic algorithm
optimizing code in compilers using parallel genetic algorithm Fatemeh Karimi
 
XP Explained
XP ExplainedXP Explained
XP Explainedvineet
 
Arch factory - Agile Design: Best Practices
Arch factory - Agile Design: Best PracticesArch factory - Agile Design: Best Practices
Arch factory - Agile Design: Best PracticesIgor Moochnick
 
What machine translation developers are doing to make post-editors happy
What machine translation developers are doing to make post-editors happyWhat machine translation developers are doing to make post-editors happy
What machine translation developers are doing to make post-editors happyIconic Translation Machines
 
Xp(Xtreme Programming) presentation
Xp(Xtreme Programming) presentationXp(Xtreme Programming) presentation
Xp(Xtreme Programming) presentationMuaazZubairi
 
Agile software development and extreme Programming
Agile software development and extreme Programming  Agile software development and extreme Programming
Agile software development and extreme Programming Fatemeh Karimi
 
A New Model for Testing
A New Model for TestingA New Model for Testing
A New Model for TestingSQALab
 
Software development project estimation
Software development project estimationSoftware development project estimation
Software development project estimationOleksandr Katrusha
 

What's hot (20)

Agile Talk 30 Jul 1o2
Agile Talk 30 Jul 1o2Agile Talk 30 Jul 1o2
Agile Talk 30 Jul 1o2
 
Going extreme-with-extreme-programming
Going extreme-with-extreme-programmingGoing extreme-with-extreme-programming
Going extreme-with-extreme-programming
 
It's XP Stupid (2019)
It's XP Stupid (2019)It's XP Stupid (2019)
It's XP Stupid (2019)
 
Agile Practices - eXtreme Programming
Agile Practices - eXtreme ProgrammingAgile Practices - eXtreme Programming
Agile Practices - eXtreme Programming
 
Twelve practices of XP_Se lect5 btech
Twelve practices of XP_Se lect5 btechTwelve practices of XP_Se lect5 btech
Twelve practices of XP_Se lect5 btech
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Advancing Testing Using Axioms
Advancing Testing Using AxiomsAdvancing Testing Using Axioms
Advancing Testing Using Axioms
 
Audrys Kažukauskas - Introduction into Extreme Programming
Audrys Kažukauskas - Introduction into Extreme ProgrammingAudrys Kažukauskas - Introduction into Extreme Programming
Audrys Kažukauskas - Introduction into Extreme Programming
 
eXtreme programming (XP) - An Overview
eXtreme programming (XP) - An OvervieweXtreme programming (XP) - An Overview
eXtreme programming (XP) - An Overview
 
optimizing code in compilers using parallel genetic algorithm
optimizing code in compilers using parallel genetic algorithm optimizing code in compilers using parallel genetic algorithm
optimizing code in compilers using parallel genetic algorithm
 
XP Explained
XP ExplainedXP Explained
XP Explained
 
eXtreme Programming
eXtreme ProgrammingeXtreme Programming
eXtreme Programming
 
XP In 10 slides
XP In 10 slidesXP In 10 slides
XP In 10 slides
 
Arch factory - Agile Design: Best Practices
Arch factory - Agile Design: Best PracticesArch factory - Agile Design: Best Practices
Arch factory - Agile Design: Best Practices
 
What machine translation developers are doing to make post-editors happy
What machine translation developers are doing to make post-editors happyWhat machine translation developers are doing to make post-editors happy
What machine translation developers are doing to make post-editors happy
 
Xp(Xtreme Programming) presentation
Xp(Xtreme Programming) presentationXp(Xtreme Programming) presentation
Xp(Xtreme Programming) presentation
 
Agile software development and extreme Programming
Agile software development and extreme Programming  Agile software development and extreme Programming
Agile software development and extreme Programming
 
Xtreme Programming
Xtreme ProgrammingXtreme Programming
Xtreme Programming
 
A New Model for Testing
A New Model for TestingA New Model for Testing
A New Model for Testing
 
Software development project estimation
Software development project estimationSoftware development project estimation
Software development project estimation
 

Similar to Effective code reviews

Quality metrics and angular js applications
Quality metrics and angular js applicationsQuality metrics and angular js applications
Quality metrics and angular js applicationsnadeembtech
 
Xen Project Contributor Training - Part 1 introduction v1.0
Xen Project Contributor Training - Part 1 introduction v1.0Xen Project Contributor Training - Part 1 introduction v1.0
Xen Project Contributor Training - Part 1 introduction v1.0The Linux Foundation
 
Extreme Programming (XP): Revisted
Extreme Programming (XP): RevistedExtreme Programming (XP): Revisted
Extreme Programming (XP): RevistedMike Harris
 
Code reviews: a short introduction
Code reviews: a short introductionCode reviews: a short introduction
Code reviews: a short introductionFreekDB
 
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
 
Code Reviews @ Quatico
Code Reviews @ QuaticoCode Reviews @ Quatico
Code Reviews @ QuaticoJan Wloka
 
Cleaning Code - Tools and Techniques for Large Legacy Projects
Cleaning Code - Tools and Techniques for Large Legacy ProjectsCleaning Code - Tools and Techniques for Large Legacy Projects
Cleaning Code - Tools and Techniques for Large Legacy ProjectsMike Long
 
Pull_Request_PAW_Shared_Rohit.pptx
Pull_Request_PAW_Shared_Rohit.pptxPull_Request_PAW_Shared_Rohit.pptx
Pull_Request_PAW_Shared_Rohit.pptxrohitagarwal24
 
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
 
Capability Building for Cyber Defense: Software Walk through and Screening
Capability Building for Cyber Defense: Software Walk through and Screening Capability Building for Cyber Defense: Software Walk through and Screening
Capability Building for Cyber Defense: Software Walk through and Screening Maven Logix
 
A brief introduction to Enterprise and Industrial UX
A brief introduction to Enterprise and Industrial UXA brief introduction to Enterprise and Industrial UX
A brief introduction to Enterprise and Industrial UXLarry Burks
 
Why Isn't Clean Coding Working For My Team
Why Isn't Clean Coding Working For My TeamWhy Isn't Clean Coding Working For My Team
Why Isn't Clean Coding Working For My TeamRob Curry
 
{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptx{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptxAmalEldhose2
 
Prashant technical practices-tdd for xebia event
Prashant   technical practices-tdd for xebia eventPrashant   technical practices-tdd for xebia event
Prashant technical practices-tdd for xebia eventXebia India
 
Adopting Agile
Adopting AgileAdopting Agile
Adopting AgileCoverity
 
What designers can learn from (code) review
What designers can learn from (code) reviewWhat designers can learn from (code) review
What designers can learn from (code) reviewIda Aalen
 
Code review best practice
Code review best practiceCode review best practice
Code review best practiceOren Digmi
 
Agile Mumbai 2020 Conference | How to get the best ROI on Your Test Automati...
Agile Mumbai 2020 Conference |  How to get the best ROI on Your Test Automati...Agile Mumbai 2020 Conference |  How to get the best ROI on Your Test Automati...
Agile Mumbai 2020 Conference | How to get the best ROI on Your Test Automati...AgileNetwork
 

Similar to Effective code reviews (20)

Quality metrics and angular js applications
Quality metrics and angular js applicationsQuality metrics and angular js applications
Quality metrics and angular js applications
 
Xen Project Contributor Training - Part 1 introduction v1.0
Xen Project Contributor Training - Part 1 introduction v1.0Xen Project Contributor Training - Part 1 introduction v1.0
Xen Project Contributor Training - Part 1 introduction v1.0
 
Extreme Programming (XP): Revisted
Extreme Programming (XP): RevistedExtreme Programming (XP): Revisted
Extreme Programming (XP): Revisted
 
Code reviews: a short introduction
Code reviews: a short introductionCode reviews: a short introduction
Code reviews: a short introduction
 
An Introduction To Software Development - Implementation
An Introduction To Software Development - ImplementationAn Introduction To Software Development - Implementation
An Introduction To Software Development - Implementation
 
Agile engineering practices
Agile engineering practicesAgile engineering practices
Agile engineering practices
 
Code Reviews @ Quatico
Code Reviews @ QuaticoCode Reviews @ Quatico
Code Reviews @ Quatico
 
Cleaning Code - Tools and Techniques for Large Legacy Projects
Cleaning Code - Tools and Techniques for Large Legacy ProjectsCleaning Code - Tools and Techniques for Large Legacy Projects
Cleaning Code - Tools and Techniques for Large Legacy Projects
 
Pull_Request_PAW_Shared_Rohit.pptx
Pull_Request_PAW_Shared_Rohit.pptxPull_Request_PAW_Shared_Rohit.pptx
Pull_Request_PAW_Shared_Rohit.pptx
 
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
 
Capability Building for Cyber Defense: Software Walk through and Screening
Capability Building for Cyber Defense: Software Walk through and Screening Capability Building for Cyber Defense: Software Walk through and Screening
Capability Building for Cyber Defense: Software Walk through and Screening
 
A brief introduction to Enterprise and Industrial UX
A brief introduction to Enterprise and Industrial UXA brief introduction to Enterprise and Industrial UX
A brief introduction to Enterprise and Industrial UX
 
Why Isn't Clean Coding Working For My Team
Why Isn't Clean Coding Working For My TeamWhy Isn't Clean Coding Working For My Team
Why Isn't Clean Coding Working For My Team
 
{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptx{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptx
 
Prashant technical practices-tdd for xebia event
Prashant   technical practices-tdd for xebia eventPrashant   technical practices-tdd for xebia event
Prashant technical practices-tdd for xebia event
 
Adopting Agile
Adopting AgileAdopting Agile
Adopting Agile
 
What designers can learn from (code) review
What designers can learn from (code) reviewWhat designers can learn from (code) review
What designers can learn from (code) review
 
Code Review for iOS
Code Review for iOSCode Review for iOS
Code Review for iOS
 
Code review best practice
Code review best practiceCode review best practice
Code review best practice
 
Agile Mumbai 2020 Conference | How to get the best ROI on Your Test Automati...
Agile Mumbai 2020 Conference |  How to get the best ROI on Your Test Automati...Agile Mumbai 2020 Conference |  How to get the best ROI on Your Test Automati...
Agile Mumbai 2020 Conference | How to get the best ROI on Your Test Automati...
 

More from nextbuild

Aws microservice keynote
Aws microservice keynoteAws microservice keynote
Aws microservice keynotenextbuild
 
How invariants help writing loops
How invariants help writing loopsHow invariants help writing loops
How invariants help writing loopsnextbuild
 
A first taste of integration with Apache Camel
A first taste of integration with Apache CamelA first taste of integration with Apache Camel
A first taste of integration with Apache Camelnextbuild
 
Microservices in the real world
Microservices in the real worldMicroservices in the real world
Microservices in the real worldnextbuild
 
Asp.net in a new world
Asp.net in a new worldAsp.net in a new world
Asp.net in a new worldnextbuild
 
Meteor - building an email client
Meteor - building an email clientMeteor - building an email client
Meteor - building an email clientnextbuild
 
Swimming upstream in the container revolution
Swimming upstream in the container revolutionSwimming upstream in the container revolution
Swimming upstream in the container revolutionnextbuild
 
Event sourcing your AngularJS applications
Event sourcing your AngularJS applicationsEvent sourcing your AngularJS applications
Event sourcing your AngularJS applicationsnextbuild
 
Make color schemes a no brainer with sass
Make color schemes a no brainer with sassMake color schemes a no brainer with sass
Make color schemes a no brainer with sassnextbuild
 
Cqrs from the trenches
Cqrs from the trenchesCqrs from the trenches
Cqrs from the trenchesnextbuild
 
Architecting for the cloud
Architecting for the cloudArchitecting for the cloud
Architecting for the cloudnextbuild
 
Finally… reliable software!
Finally… reliable software!Finally… reliable software!
Finally… reliable software!nextbuild
 
Cucumber spec - a tool takes your bdd to the next level
Cucumber spec - a tool takes your bdd to the next levelCucumber spec - a tool takes your bdd to the next level
Cucumber spec - a tool takes your bdd to the next levelnextbuild
 

More from nextbuild (13)

Aws microservice keynote
Aws microservice keynoteAws microservice keynote
Aws microservice keynote
 
How invariants help writing loops
How invariants help writing loopsHow invariants help writing loops
How invariants help writing loops
 
A first taste of integration with Apache Camel
A first taste of integration with Apache CamelA first taste of integration with Apache Camel
A first taste of integration with Apache Camel
 
Microservices in the real world
Microservices in the real worldMicroservices in the real world
Microservices in the real world
 
Asp.net in a new world
Asp.net in a new worldAsp.net in a new world
Asp.net in a new world
 
Meteor - building an email client
Meteor - building an email clientMeteor - building an email client
Meteor - building an email client
 
Swimming upstream in the container revolution
Swimming upstream in the container revolutionSwimming upstream in the container revolution
Swimming upstream in the container revolution
 
Event sourcing your AngularJS applications
Event sourcing your AngularJS applicationsEvent sourcing your AngularJS applications
Event sourcing your AngularJS applications
 
Make color schemes a no brainer with sass
Make color schemes a no brainer with sassMake color schemes a no brainer with sass
Make color schemes a no brainer with sass
 
Cqrs from the trenches
Cqrs from the trenchesCqrs from the trenches
Cqrs from the trenches
 
Architecting for the cloud
Architecting for the cloudArchitecting for the cloud
Architecting for the cloud
 
Finally… reliable software!
Finally… reliable software!Finally… reliable software!
Finally… reliable software!
 
Cucumber spec - a tool takes your bdd to the next level
Cucumber spec - a tool takes your bdd to the next levelCucumber spec - a tool takes your bdd to the next level
Cucumber spec - a tool takes your bdd to the next level
 

Recently uploaded

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Recently uploaded (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Effective code reviews

  • 2. Think profit-based, not cost-based. TomTom devices 2
  • 3. Think profit-based, not cost-based. TomTom products Maps Navigation Traffic Fleet-management Fitness 3
  • 4. Think profit-based, not cost-based. Introduction • Theory • Creates awareness, explains philosophy • Defines “defect” and explains its impact • Practice • How to improve the efficiency of reviews? • What is role and mindset of author and reviewer? • How to execute reviews?
  • 5. Think profit-based, not cost-based. Perfect code What is perfect code? • Working • Readable • Maintainable • Extendable • Elegant • Simple and clear • Well documented • … Easy to recognize, hard to describe
  • 6. Think profit-based, not cost-based. Not so perfect code Why is real code not so perfect? • Time-boxed • Lack of experience • Change on change • Edge cases • Built on legacy • Mindset author (problem solving, result oriented, pragmatic, …) • Multiple authors (own mind, no machines) Easy to describe, hard to fight
  • 7. Think profit-based, not cost-based. Definition of defect What is a defect? • Highly unlikely defects • Race conditions • Timing issues • Extreme load • Trivial defects • Subjective term • Hard to predict impact of a defect Defect: anything that may cause any additional cost later on
  • 8. Think profit-based, not cost-based. Cost of defects Cost to fix defect grows exponentially Consider 4 stages: design  develop  test  production Every stage adds additional cost factor of 10 • code review instead of test: 10x cost savings • code review in stead of production: 100x cost savings Finding/fixing defects early is always faster and cheaper than not finding or not fixing them
  • 9. Think profit-based, not cost-based. Cost of defects 1 single defect will pay for 100 99 defects never ever causes a problem 1 single defect causes a problem in production Question is: which one? No significant additional cost fixing 5 or 50 defects Building, Reviewing, Testing, Deploying Fix ALL defects that you can find (no priorities)
  • 10. Think profit-based, not cost-based. Fix ALL defects What happens next? • No trivial defects any more • No discussion on minor and major, just defect • No subjective reasoning Cleaner and more useful statistics as well • Code gets higher quality and is easier to review Increased developer pride, reduced ‘broken window’ effect
  • 11. Think profit-based, not cost-based. Change your thinking! The cost of fixing everything is small, and the profit is much higher than the cost Fix all defects that are found • Ensure defects that cause issues are fixed • Ensure defect that pays for all other defects is fixed Think profit-based, not cost-based
  • 12. Think profit-based, not cost-based. Statistics This is about applied statistics Good engineers respect statistics You are an engineer… respect and obey statistics! Know: Many defects will never cause an issue if left unfixed So: Fixing an individual defect does not necessarily reduce cost And: Some (unlikely) defects will lead to great cost if left unfixed But: You cannot tell which defect will cause an issue Not about individual defects or reviews, about applying this practice continuously -> benefits
  • 13. Think profit-based, not cost-based. Theory summary Defects enter our code for a lot of reasons Defect is anything that cause additional costs Cost to fix defect grows exponentially Fix ALL defects Think profit-based It is all about statistics
  • 15. Think profit-based, not cost-based. Introduction • Theory (previous session) • Creates awareness, explains philosophy • Defines “defect” and explains its impact • Practice • How to improve the efficiency of reviews? • What is role and mindset of author and reviewer? • How to execute reviews?
  • 16. Think profit-based, not cost-based. Improve quality How can reviews address mentioned issues? • Reviewer has different goal so different mindset • Author solves the problem • Reviewer checks code quality (guardian) • Solution fits context • Solution adheres to good practices • Reviewer is not bothered by time (dead-line) • Reviewer looks at code from different angle Code review is an easy tool to increase quality
  • 17. Think profit-based, not cost-based. Increase efficiency of reviews What can be changed to become effective? • A: Ensure changes are ready (static code analysis, annotate) • A: Limit number of reviewers (default is 2) • R: Find as many defects as possible (time-boxed) • R: Be thorough (address everything that catches the eye) • Sharing knowledge • Establish team-culture (abbreviations, code duplication) • A: Fix ALL defects (no priorities) • R+A: work together, same goal (peers) • No need to defend yourself: “finding more defects is better”
  • 18. Think profit-based, not cost-based. Role and mindset author Problem solver – solution driven – time aware • Prepare review (static code analysis, review yourself, annotate) • Remarks aim to increase quality of code • not to discuss author’s ability to code (no defense) • Normally answer questions with comment in code • Review will almost never be read again, code will • Address ALL found defects (no priorities) • minor defects take very little time to fix (no discussion required) • Handle clearly incorrect remarks respectfully • Discuss off-line; comment in code? • Author is end responsible for changes and quality
  • 19. Think profit-based, not cost-based. Role and mindset reviewer Guardian – quality driven – time-boxed • Execute review promptly (do not become a bottleneck) • Make only remarks to improve quality of code • Do not offer solutions or “better alternatives” • Do not “educate” the author (off-line, coaching) • Thorough, relentless AND respectful • Can never find too many defects (slow pace) • Avoid religious wars, no personal flavors, only technical • Explain why something needs improvement • Ignore amount of rework to fix defect • Always re-review after author updated code (prompt)
  • 20. Think profit-based, not cost-based. Tone of review • Be neutral, explain your interpretation • Be aware of different mindset • Be respectful (no SHOUTING!, no telling, no lecture, use keywords) • Explain with reasoning in case technical solution needs improvement • Single problem may have multiple solutions • Search for reasons of unclarity (do not ask why to quickly) Remember goal • author is responsible for code quality • reviewer helps author to establish level of quality • working together as peers to improve quality
  • 21. Think profit-based, not cost-based. Examples - What is this about? + The context is unclear, can you explain… - This sucks… + This causes issues like x, y, z… - Did you read the documentation at all? + The documentation specifies x rather than doing y… - You should implement this completely different! + Doing x causes issues y and z in… - NO, NO, NO… + This causes issues x, y, z in…
  • 22. Think profit-based, not cost-based. Defect remark strategy • Gather context information (design, user-story, JIRA-issue) • Focus on changes, keep eye on context • Search for patterns and inconsistencies • Check complexity (bang-for-buck, keep-it-simple-stupid) • Let unconscious mind help (bell ringing -> investigate) • Act like logical compiler (do not interpret code -> read code) • Ask if something is unclear (comment should be added) • Mark all style defects (diminishes quickly, static code analysis) • Code removal – check correct and complete • Use checklists
  • 23. Think profit-based, not cost-based. Practice summary Author is responsible for code quality Reviewer helps author to establish level of quality Author and reviewer work together as peers Reviewer is thorough, relentless and prompt Author fixes all found defects Reviewer review all changesBe polite
  • 24. Think profit-based, not cost-based. Code review rules Time-boxed period to polish the code
  • 25. Thank you Any questions? William Deurwaarder Head of Developer Relations, TomTom E-mail: william.deurwaarder@tomtom.com Website: http://developer.tomtom.com
  • 26. Think profit-based, not cost-based. Code-review figures Indication of important figures • Minimum review time per session 5 minutes • Maximum review time per session 60 – 90 minutes • Maximum review size per session 200 – 400 LOC • Default number of reviewers 2 • Maximum inspection rate 300 – 500 LOC / hour
  • 27. Think profit-based, not cost-based. Checklist for code-review (1/4) Check consistency with design (see change in bigger scope) • Verify edge-cases Check consistency interface changes • Scope changed (private to public; why?) • Order of parameters (same in all methods) • Symmetrical methods • Use of default parameters • Implementation details leak through in interface Check level of containment (increasingly risky, increase scope) • Within method • Within private methods • Within public class methods • Within public interface of system (NavKit)
  • 28. Think profit-based, not cost-based. Checklist for code-review (2/4) Check complexity • Keep algorithms clean (no exceptional cases) • Verify edge-cases… throw exception in stead? • Try what-if scenarios Check exception handling • Is exception caught? • Adheres to exception handling policy • Exception handling aligned with surrounding code Check readability, clarity (decrease time to understand code) • Remove code duplication (extract method) • Check functionality of method (reduce size of method) • Add comments to increase readability
  • 29. Think profit-based, not cost-based. Checklist for code-review (3/4) Check includes/imports (needed? correct?) Check NULL-pointer behavior (can reference be used?) Check const-behavior (consistent, no const_cast) Check algorithms for one-off errors Check resource leakage (memory, file handles, …) Check multi-threading behavior • Race-conditions • Dead-lock situations Check usage of members and local variables • No state duplication (only for measured performance improvement) • Superfluous • No re-use of variables with different meaning
  • 30. Think profit-based, not cost-based. Checklist for code-review (4/4) Check type-casts (discourage them) Check surrounding comments Check correct usage of libraries (STL, OSAL, …) Check “early” optimization • Is measurement in place? • Is there comment with explanation? Check use of deprecated code • NavKit-examples: NavKitEnvironment, Tdes, CString Check use of discouraged patterns • Singleton Check if tests exists