SlideShare a Scribd company logo
A Second Set Of Eyes
Getting The Most From Code Reviews
Ben McCormick
WhatCounts
Twitter: @_benmccormick
Blog: http://benmccormick.org
Newsletter: http://benmccormick.org/subscribe
Who Am I?
• UI Dev Manager @ WhatCounts
• Reviewing Code for > 10 years
• Live in Durham
• Blog @ benmccormick.org
What To Expect
• Why This Talk?
• Why Review Code?
• How To Have Better Reviews
• Creating A Code Review Culture
• Q & A (as time allows)
Why Talk About Code Reviews?
• Devs spend time on it (3+ hrs a week at Google)
• It’s rarely taught or discussed
• It’s a skill that can be improve
• It can make our jobs better / worse
Why Review Code?
• Better Code
• Knowledge Sharing
• Implementing Architecture
• Creating A Feedback Loop
Better Code
• Find Bugs
• Suggesting better patterns
• Nitpick Style
Knowledge Sharing
• Micro Sharing - More people who understand a piece
of code
• Macro Sharing - Exposure to new patterns and ways of
doing things
“Why Review Code” Sophie Alpert https://sophiebits.com/2018/12/25/why-review-code.html
Implementing Architecture
• Architecture is planned (or not) in design meetings and
technical documentation
• Code Reviews help flesh it out
• Code Reviews are great places to challenge, discuss
and improve architecture decisions or gaps
• Especially good for less formal processes
“A Philosophy Of Software Design” John Ousterhout https://amzn.to/2XxQM03
Feedback Loops
Deliberate practice [is when]
(1)your attention is focused tightly on a
specific skill you’re trying to improve […]
(2)You receive feedback so you can
correct your approach to keep your
attention exactly where it is most
productive.
- Cal Newport, Deep Work
“Deep Work” Cal Newport https://amzn.to/2XCfn3Y
Why Review Code? (Summary)
• Better Code
• Knowledge Sharing
• Implementing Architecture
• Feedback Loops
How To Have Better
Code Reviews
• Get Better Code Reviews
• Annotate Pull Requests
• Make Atomic Pull Requests
• Give Better Code Reviews
• Radical Candor
• Don’t just critique
Get Better Reviews:
Annotate Pull Requests
Get Better Reviews:
Atomic Pull Requests
Give Better Reviews:
Radical Candor
“Radical Candor” by Kim Scott https://www.radicalcandor.com/
Give Better Code Reviews:
Don’t just critique
• Ask questions
• Affirm things that are well done
• Make suggestions
How To Have Better
Code Reviews (Summary)
• Get Better Code Reviews
• Annotate Pull Requests
• Make Atomic Pull Requests
• Give Better Code Reviews
• Radical Candor
• Don’t just critique
Create A Code Review Culture
• Make Reviews Multi-Directional
• Hold Reviewers Accountable
• Get The Process Right
Multi-Directional Code Reviews
• Senior -> Junior
• Mentoring
• Bug Catching
• Junior -> Senior
• Codebase Learning
• Readability testing
• Peer -> Peer
• Architecture Discussion
• Bug catching
• “Lottery Bus” insurance
Accountability
• This is about team culture
• Reviewer and author should be equally
responsible and accountable for code quality
• (Accountability != blame)
Get The Process Right
• Match technology to your process
• Use Checklists
• Leave margin for changes
Create A Code Review Culture
(Summary)
• Make Reviews Multi-Directional
• Hold Reviewers Accountable
• Get The Process Right
Ben McCormick
WhatCounts
Twitter: @_benmccormick
Blog: http://benmccormick.org
Newsletter: http://benmccormick.org/subscribe
Questions?

More Related Content

PPTX
SEOProSco - Penguin: The Cause, The Cure & The Future
PDF
Code Reviews @ Quatico
PPTX
Code Club - a Fight Club inspired approach to software inspection and review
PPTX
Clean Code III - Software Craftsmanship
PDF
Getting Things Done at Scale
PPTX
Coding Standard And Code Review
PDF
Xen Project Contributor Training - Part 1 introduction v1.0
PPT
Code reviews: a short introduction
SEOProSco - Penguin: The Cause, The Cure & The Future
Code Reviews @ Quatico
Code Club - a Fight Club inspired approach to software inspection and review
Clean Code III - Software Craftsmanship
Getting Things Done at Scale
Coding Standard And Code Review
Xen Project Contributor Training - Part 1 introduction v1.0
Code reviews: a short introduction

Similar to A Second Set Of Eyes: Getting The Most From Code Reviews (20)

PPTX
Developing a Culture of Quality Code at Givelify (Tech Talk)
PPTX
Digital Design Survey: Week 5 lecture
PDF
How to successfully grow a code review culture
KEY
CodeIgniter for Startups, cicon2010
PPTX
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...
PPTX
Code Review Best Practices
PDF
What designers can learn from (code) review
PPTX
Effective Code Review (Or How To Alienate Your Coworkers)
PDF
Triple your blog post frequency
PPTX
Untangling - fall2017 - week5
PPTX
A Brief Introduction to Test-Driven Development
PDF
Three pillars of components in the design system
PDF
Effective code reviews
PPTX
Using the Wisdom of the Crowd for Content Excellence
PDF
SME Cleveland SEO Workshop March 2012
PPTX
Peer review
PDF
Search Engine Optimization: Rank Higher, Sell More!
PPTX
Tom Livingstone's Agency Life - An Insight Into Our Process
PDF
What am i buying understanding website cost and technology 17 ntc
PPTX
How to Create Advanced Surveys with Logic, Conditions and Piping
Developing a Culture of Quality Code at Givelify (Tech Talk)
Digital Design Survey: Week 5 lecture
How to successfully grow a code review culture
CodeIgniter for Startups, cicon2010
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...
Code Review Best Practices
What designers can learn from (code) review
Effective Code Review (Or How To Alienate Your Coworkers)
Triple your blog post frequency
Untangling - fall2017 - week5
A Brief Introduction to Test-Driven Development
Three pillars of components in the design system
Effective code reviews
Using the Wisdom of the Crowd for Content Excellence
SME Cleveland SEO Workshop March 2012
Peer review
Search Engine Optimization: Rank Higher, Sell More!
Tom Livingstone's Agency Life - An Insight Into Our Process
What am i buying understanding website cost and technology 17 ntc
How to Create Advanced Surveys with Logic, Conditions and Piping
Ad

More from Ben McCormick (6)

PPTX
Saving Time By Testing With Jest
PPTX
Gatsby intro
PPTX
Vim survival guide
PDF
Decorators Lightning Talk for Triangle JavaScript
PPTX
Backbonemeetup
PDF
Component Based Development
Saving Time By Testing With Jest
Gatsby intro
Vim survival guide
Decorators Lightning Talk for Triangle JavaScript
Backbonemeetup
Component Based Development
Ad

Recently uploaded (20)

PDF
Digital Logic Computer Design lecture notes
PPTX
Construction Project Organization Group 2.pptx
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
Welding lecture in detail for understanding
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
Structs to JSON How Go Powers REST APIs.pdf
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PDF
PPT on Performance Review to get promotions
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
web development for engineering and engineering
PPTX
additive manufacturing of ss316l using mig welding
PPT
Project quality management in manufacturing
Digital Logic Computer Design lecture notes
Construction Project Organization Group 2.pptx
CYBER-CRIMES AND SECURITY A guide to understanding
Lesson 3_Tessellation.pptx finite Mathematics
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Foundation to blockchain - A guide to Blockchain Tech
Welding lecture in detail for understanding
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Structs to JSON How Go Powers REST APIs.pdf
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPT on Performance Review to get promotions
Embodied AI: Ushering in the Next Era of Intelligent Systems
web development for engineering and engineering
additive manufacturing of ss316l using mig welding
Project quality management in manufacturing

A Second Set Of Eyes: Getting The Most From Code Reviews

  • 1. A Second Set Of Eyes Getting The Most From Code Reviews Ben McCormick WhatCounts Twitter: @_benmccormick Blog: http://benmccormick.org Newsletter: http://benmccormick.org/subscribe
  • 2. Who Am I? • UI Dev Manager @ WhatCounts • Reviewing Code for > 10 years • Live in Durham • Blog @ benmccormick.org
  • 3. What To Expect • Why This Talk? • Why Review Code? • How To Have Better Reviews • Creating A Code Review Culture • Q & A (as time allows)
  • 4. Why Talk About Code Reviews? • Devs spend time on it (3+ hrs a week at Google) • It’s rarely taught or discussed • It’s a skill that can be improve • It can make our jobs better / worse
  • 5. Why Review Code? • Better Code • Knowledge Sharing • Implementing Architecture • Creating A Feedback Loop
  • 6. Better Code • Find Bugs • Suggesting better patterns • Nitpick Style
  • 7. Knowledge Sharing • Micro Sharing - More people who understand a piece of code • Macro Sharing - Exposure to new patterns and ways of doing things “Why Review Code” Sophie Alpert https://sophiebits.com/2018/12/25/why-review-code.html
  • 8. Implementing Architecture • Architecture is planned (or not) in design meetings and technical documentation • Code Reviews help flesh it out • Code Reviews are great places to challenge, discuss and improve architecture decisions or gaps • Especially good for less formal processes “A Philosophy Of Software Design” John Ousterhout https://amzn.to/2XxQM03
  • 9. Feedback Loops Deliberate practice [is when] (1)your attention is focused tightly on a specific skill you’re trying to improve […] (2)You receive feedback so you can correct your approach to keep your attention exactly where it is most productive. - Cal Newport, Deep Work “Deep Work” Cal Newport https://amzn.to/2XCfn3Y
  • 10. Why Review Code? (Summary) • Better Code • Knowledge Sharing • Implementing Architecture • Feedback Loops
  • 11. How To Have Better Code Reviews • Get Better Code Reviews • Annotate Pull Requests • Make Atomic Pull Requests • Give Better Code Reviews • Radical Candor • Don’t just critique
  • 13. Get Better Reviews: Atomic Pull Requests
  • 14. Give Better Reviews: Radical Candor “Radical Candor” by Kim Scott https://www.radicalcandor.com/
  • 15. Give Better Code Reviews: Don’t just critique • Ask questions • Affirm things that are well done • Make suggestions
  • 16. How To Have Better Code Reviews (Summary) • Get Better Code Reviews • Annotate Pull Requests • Make Atomic Pull Requests • Give Better Code Reviews • Radical Candor • Don’t just critique
  • 17. Create A Code Review Culture • Make Reviews Multi-Directional • Hold Reviewers Accountable • Get The Process Right
  • 18. Multi-Directional Code Reviews • Senior -> Junior • Mentoring • Bug Catching • Junior -> Senior • Codebase Learning • Readability testing • Peer -> Peer • Architecture Discussion • Bug catching • “Lottery Bus” insurance
  • 19. Accountability • This is about team culture • Reviewer and author should be equally responsible and accountable for code quality • (Accountability != blame)
  • 20. Get The Process Right • Match technology to your process • Use Checklists • Leave margin for changes
  • 21. Create A Code Review Culture (Summary) • Make Reviews Multi-Directional • Hold Reviewers Accountable • Get The Process Right
  • 22. Ben McCormick WhatCounts Twitter: @_benmccormick Blog: http://benmccormick.org Newsletter: http://benmccormick.org/subscribe Questions?

Editor's Notes

  • #2: Hey everyone! We have a ton of speakers tonight, so I’m gonna get right into it.
  • #3: Quick Intro: My name is Ben. I work a block up the street at WhatCounts (formerly Windsor Circle), I’ve been in professional software development for about a decade now, and have lived in Durham for even longer than that. I write about shipping web software at my blog, feel free to check it out.
  • #4: Cool, so… here’s the gameplan. Talks on code review are a bit unusual, so I’m gonna stand up here for 30 seconds and convince you I’m not wasting your time. Then we’ll talk about why this code review thing is useful, how to do it better, and finally how to create an environment where everyone can get more benefits from code reviews.
  • #5: So why is this a better use of your time than reading tweets for the next 20 minutes? Raise your hand if you do code reviews or have your code reviewed as part of your job Raise your hand if you contribute to or are interested in contributing to open source projects? < yeah you all are going to encounter code reviews too When Google did an internal research project on code reviews, they found that developers spent on average over 3 hours a week on code reviews, with some developers devoting considerably more time reviewing code. This aligns with my experience on teams that regularly review code. Despite this being a regular part of many developers rhythms its something that I’ve rarely seen discussed in conferences, meetups or blogs. Which is a shame, because its something that you can definitely get better at. Finally, good code reviews can make your job better by making things collaborative and helping you be better. Bad ones can exclude people and miss opportunities to improve software And helping you get better is the goal today. So lets start by understanding what value code review brings.
  • #6: I’m going to focus on 4 main areas of value for code review. These aren’t exclusive, you can probably come up with more, but I’ve found these to be universal benefits
  • #7: Ok, so this is probably why most people would say they’re doing reviews. We’re catching bugs, and pointing out opportunities for improvement when somebody doesn’t know about a particular pattern or library. I *don’t* recommend using code review for stylistic nitpicks. If you want to enforce common code conventions, use a tool. There are many excellent tools these days, including prettier and eslint for JavaScript. When code reviews get used to barter over style, they’re well on their way to unproductively. We all have a limited supply of attention. Code reviews should be for the things you can’t automate.
  • #8: I owe the breakdown of this set of benefits to Sophie Alpert, the former manager of the React team at Facebook. Sophie makes a distinction between micro and macro knowledge sharing: Micro is more about increasing team knowledge of the code base, which helps people do more and mitigates the “lottery bus” factor: when an employee leaves suddenly because they won the lottery or were hit by a bus Macro is about learning from your coworkers and seeing new ways of approaching problems that you hadn’t experienced before. Note that while code reviews are ostensibly to help the review or the codebase, these benefits are actually for the *reviewer*. Code reviews have more than one impact
  • #9: One of the books that changed how I think about code reviews was “A Philosophy Of Software Design” by John Ousterhout. It’s a book about software architecture and design, but the authors recommended tactic for implementing his suggestions is to use code reviews to see how well the codebase and new code supports good architecture. For instance after reading about how modules that know too much about each other can cause problems, spend time looking for patterns like that in your code reviews. Most teams I’ve worked on in my career have been on the informal end of the process in terms of how much time we spend on upfront designs and explicit architecture models. So code review discussions have always been really important in defining the architecture But even if you are more formal, code reviews are where theories meet reality. This is also very relevant to open source projects. It’s a common pattern in the open source world to ask somebody who has a suggestion for an architecture change to open a PR for discussion, especially if that person isn’t the maintainer.
  • #10: In his book Deep Work, Cal Newport argues that the key to mastery of any skill is deliberate practice, which consists of “doing something” and “getting feedback on it” The first 3 points are all specific versions of the last point: code reviews help us get better by defining a feedback loop. There’s an old saying about how you can have 10 years of experience in a job, or 1 year of experience 10 times. Getting feedback on our work and learning where we need to improve gives us the opportunity to get better.
  • #11: Alright, so that’s why we review code: Better code, knowledge sharing, implementing architecture and feedback loops. On to how to do it better
  • #12: Ok, so 2 parts of having better code reviews. Getting better ones when you’re submitting code, and giving better ones when you’re reviewing
  • #13: So this is probably the single biggest practical thing I’ve done to get better reviews: I’ve learned that annotating my pull requests with additional context has resulted in much better feedback during reviews. Annotating = comments in bitbucket/github. Not just for reviewers The types of things I annotate are Giving reviewers a high level picture of how the changes fit together Reference when a particular change connects to a change in another file Give context for why a particular section of code changed (as opposed to what it does or how it works, which should be evident in the code + comments in the diff) Asking questions or highlighting particularly important parts of the diff I have found that this lowers the burden on reviewers as they try to understand context, and helps them focus on the important stuff. Anecdotally it has led to much more useful feedback and less rubber stamping of my PRs.
  • #14: So… this tweet speaks for itself. Split apart your changes into digestible review sizes as much as possible. In my experience somewhere around 150 lines things start getting pretty dicey, and most PRs should be much smaller than that.
  • #15: Ok, so on to “giving” better code reviews. This is where the human factor really comes in. The chart on the slide is my favorite framework for thinking about feedback You give good feedback when you care personally and are willing to challenge directly. In code reviews that means taking the time to get things right and tell the reviewee what you think, but do do so with an attitude of genuinely wanting to help them and make the end result better. I think you can imagine what the other quadrants look like: empty compliments, rubber stamping or nitpicking , and abrasive or domineering put downs. Code reviews are one of the most human parts of our day to day work as developers, and getting better at it means getting better at working with humans
  • #16: So more about dealing with humans: we generally don’t respond well to constant streams of negativity. For most people their defense mechanisms kick in at that point and they start to tune people out. In fact, while criticism is sometimes necessary, it is often the least impactful way to give feedback. Instead mix it up. Ask about things you don’t understand, or think you may be lacking context on. Be humble. Tell people what they’ve done well, and make suggestions for how things could be better (without necessarily saying that its wrong now).
  • #18: Ok, final section here is about how we help teams do this better. This is most relevant to the managers, maintainers and leads in the room, but anybody can speak up on these things and push for change
  • #19: One thing I think a lot of developers assume about code review is that its about senior developers keeping more junior developers “in line”. But code reviews can actually be useful in multiple directions. They just have different benefits each way. Note that Senior and Junior here are relative terms. Its about when one person has more experience and comfort with contributing to a particular code base, either through years of experience, aptitude, or familiarity with the subject matter. (read the slide :) )
  • #20: So this is my best “manager hat” advice of the talk: if you want your team to get value out of code reviews, the best thing you can do is to treat it as an equal activity to writing the code. That means that its equally valued as time spent, and when bugs come back both the coder and reviewer should be held accountable. This doesn’t mean “blaming the reviewer”, it just means when you’re examining any quality problems and looking for solutions, you should be working with coders AND reviewers to find improvements and not accepting a “rubber stamping” attitude towards reviews.
  • #21: Finally, a lot of teams like the ideas of code reviews but aren’t set up to do them. So here are my quick hit tips Get the right technology. I’ve worked on teams that used old version control systems and sent patches along by email for review. Code Review on those teams was ok, but often got skimped because it was so much work. Modern tools like github, bitbucket, gitlab, Phabricator and others make this MUCH lighter weight. And when it’s easier, teams do it more. I recommend setting up some checklists of common things to look for in code reviews. These shouldn’t be exhaustive, but outline the common things that get missed, 3-7 items, and update it over time. Maybe have specialty checklists for different parts of the code and work it into your process. To be honest, I’m still experimenting with this stuff, will probably write about it once I’ve used it a bit more with my team Lastly, code reviews are severely limited if you don’t leave time for developers to act on a reviewers suggestion. If developers are overcommitting to the point where they can’t iterate after a reviewer comments, that should be addressed and fixed.
  • #22: (read list) Ok, thats all I have! Any questions?