Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in...
Transcript of Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in...
![Page 1: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/1.jpg)
Code
Review
Best practices
![Page 2: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/2.jpg)
Why are we
talking about it?
![Page 3: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/3.jpg)
Not useful to spread know how
Not a good way to mentor juniors
Out of office commits not reviewed
Feeling it is not done seriously
Encodo Perception
![Page 4: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/4.jpg)
Benefits
![Page 5: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/5.jpg)
The Ego Effect
Benefits
![Page 6: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/6.jpg)
Why we were talking about it
Finding Bugs
![Page 7: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/7.jpg)
Early Fixing
![Page 8: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/8.jpg)
The Ego Effect
Team Awareness and Transparency
Finding alternative Solutions to Problems
Code Improvement
Benefits
![Page 9: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/9.jpg)
«the discipline of explaining your code to your peers»
Expectations, Outcomes, and Challenges of modern Code Review
Benefits
![Page 10: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/10.jpg)
Technical
Discussions
![Page 11: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/11.jpg)
The Ego Effect
Team Awareness and Transparency
Finding alternative Solutions to Problems
Code Improvement
Knowledge Transfer (Increased Bus Factor)
Finding Defects
Benefits
![Page 12: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/12.jpg)
Costs developer Time
Interruptions cost time
No quality assurance measure
-> A creating quality measure
Drawbacks
![Page 13: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/13.jpg)
Types
![Page 14: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/14.jpg)
![Page 15: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/15.jpg)
Formal Inspection
Pair Programming
Over the shoulder
Tool Based
Types
![Page 16: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/16.jpg)
Practice lightweight code reviews
Face to Face, Said, Sync
vs.
Tool, Written, Async
Types – Best Practices
![Page 17: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/17.jpg)
Best
Practices
![Page 18: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/18.jpg)
Less than ??? lines of code
Best Practices – In Numbers
![Page 19: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/19.jpg)
Less than 400 lines of code
Best Practices – In Numbers
![Page 20: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/20.jpg)
Less than 400 lines of code
Not more than ??? loc / hour
Best Practices – In Numbers
![Page 21: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/21.jpg)
Less than 400 lines of code
Go Slow, not more than 500 loc / hour
Best Practices – In Numbers
![Page 22: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/22.jpg)
Less than 400 lines of code
Go Slow, not more than 500 loc / hour
Maximum of ??? minutes
Best Practices – In Numbers
![Page 23: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/23.jpg)
Less than 400 lines of code
Go Slow, not more than 500 loc / hour
Maximum of 60 minutes
Best Practices – In Numbers
![Page 24: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/24.jpg)
Less than 400 lines of code
Go Slow, not more than 500 loc / hour
Maximum of 60 minutes
Maximum of ??? reviewers
Best Practices - In Numbers
![Page 25: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/25.jpg)
Less than 400 lines of code
Go Slow, not more than 500 loc / hour
Maximum of 60 minutes
Maximum of 2 reviewers
Best Practices - In Numbers
![Page 26: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/26.jpg)
In a
hurry?
![Page 27: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/27.jpg)
Due to selected code parts
– Just the Diffs
– Just the Scariest Code
– Only Unit Tests
On demand
– E.g. Feature Freeze
– Triggered by Developer
Best Practices – Getting Faster
![Page 28: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/28.jpg)
Use Tooling - Formatter, Compiler, Metrics, …
– Modern IDE + Extensions
– Continuous Integration
Collect Commits
Practice
Best Practices – Getting Faster
![Page 29: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/29.jpg)
How
![Page 30: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/30.jpg)
How!
![Page 31: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/31.jpg)
Review it yourself
How - Author
![Page 32: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/32.jpg)
How – by Understanding
![Page 33: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/33.jpg)
Review it yourself
Provide Context and Design Rational
– Proposal: 2 Paragraphs in Commit Message
How - Author
![Page 34: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/34.jpg)
Discussion
![Page 35: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/35.jpg)
Review it yourself
Provide Context and Design Rational
– 2 Paragraphs in Commit Message
Embrace Feedback - Give it a thought
How - Author
![Page 36: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/36.jpg)
Generalizing
- Always use this… / Never do that…
+ Can you show me what you mean?
How - Reviewer
![Page 37: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/37.jpg)
Generalizing
- Always use this… / Never do that…
+ Can you show me what you mean?
Ask don't tell
+ What do you think about …?
+ Did you consider…?
+ Can you clarify … ? (What the hell is going on here)
How - Reviewer
![Page 38: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/38.jpg)
Guessing Game
- How can we make this better?
+ I feel confused. Where should we start?
Negative Questions
- Why didn’t you just …?
+ Be positive
How – Question everything?
![Page 39: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/39.jpg)
Conflict
![Page 40: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/40.jpg)
Insist on high quality reviews
-> But agree to disagree
Handle disagreement
How - Conflict
![Page 41: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/41.jpg)
What?
![Page 42: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/42.jpg)
General- and business logic
Architecture and design
Readability and maintainability
Performance
Security
What
![Page 43: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/43.jpg)
General- and business logic
Architecture and design
Readability and maintainability
Performance
Security
What
![Page 44: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/44.jpg)
Checklists
Personal Checklists
What
![Page 45: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/45.jpg)
Checklists
Personal Checklists
Encodo experience
What
![Page 46: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/46.jpg)
What do you
value?
![Page 47: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/47.jpg)
Here
![Page 48: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/48.jpg)
Encodo Code Review Process
![Page 49: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/49.jpg)
Author shall pick appropriate Reviewer
Not over 1h
Not more than 200 loc at once to review
Small Commits, Avoid big code changes
If you still happen to have a big change, only sync Face to Face reviews!
Encodo Best practice constraints
![Page 50: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/50.jpg)
Foster Strong Review
Culture
![Page 51: Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in 2006 – Expectations, Outcomes, and Challenges of modern Code Review Alberto Bacchelli](https://reader036.fdocuments.us/reader036/viewer/2022070211/60fddcb29d0fe126096752d9/html5/thumbnails/51.jpg)
Sources– Best Kept Secrets of Peer Code Review
Jason Cohen in 2006
– Expectations, Outcomes, and Challenges of modern Code Review
Alberto Bacchelli and Christian Bird, May 2013
http://research.microsoft.com/apps/pubs/default.aspx?id=180283
– best-practices-for-peer-code-reviewhttps://smartbear.com/learn/code-review/best-practices-for-peer-code-review/
– Better Code Review https://www.youtube.com/watch?v=rHVlFOB5BpU
– RailsConf 2015 - Implementing a Strong Code-Review Culture
https://www.youtube.com/watch?v=PJjmw9TRB7s
– How to stop wasting your time and start performing useful code reviews by Maria Khalusova, jetbrains
https://www.youtube.com/watch?v=VRnMzMpSeag
– 11 Best Practices for Peer Code Review - IBM Innovate Conference 2011
Jason Cohen - Author of "Best kept Secrets of Peer Code Review"
https://www.youtube.com/watch?v=hgNAwAdhwoQ
– Code Review for Teams Too Busy to Review CodeBrandan Humphreys, Atlassian
https://www.youtube.com/watch?v=1m3eRFeCInY
Images• https://www.flickr.com/photos/mongogushi/
• https://www.flickr.com/photos/jwhitesmith/
• https://www.flickr.com/photos/mwichary/
• https://www.flickr.com/photos/bike/
• https://www.flickr.com/photos/michaelpardo/
• https://www.flickr.com/photos/sreichenbach/
• http://pcweenies.com/comic/oreville-and-bugs
• https://www.flickr.com/photos/unlistedsightings/
• https://www.flickr.com/photos/joncandy/
Diagrams• https://support.smartbear.com/support/media/re
sources/cc/Episode_1_TheCaseForCodeReview.pdf
• http://research.microsoft.com/pubs/180283/ICSE%202013-codereview.pdf
• Encodo Wiki
Sources