Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in...

Post on 28-Feb-2021

3 views 0 download

Transcript of Code Review - Encodo Systems AG...Sources – Best Kept Secrets of Peer Code Review Jason Cohen in...

Code

Review

Best practices

Why are we

talking about it?

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

Benefits

The Ego Effect

Benefits

Why we were talking about it

Finding Bugs

Early Fixing

The Ego Effect

Team Awareness and Transparency

Finding alternative Solutions to Problems

Code Improvement

Benefits

«the discipline of explaining your code to your peers»

Expectations, Outcomes, and Challenges of modern Code Review

Benefits

Technical

Discussions

The Ego Effect

Team Awareness and Transparency

Finding alternative Solutions to Problems

Code Improvement

Knowledge Transfer (Increased Bus Factor)

Finding Defects

Benefits

Costs developer Time

Interruptions cost time

No quality assurance measure

-> A creating quality measure

Drawbacks

Types

Formal Inspection

Pair Programming

Over the shoulder

Tool Based

Types

Practice lightweight code reviews

Face to Face, Said, Sync

vs.

Tool, Written, Async

Types – Best Practices

Best

Practices

Less than ??? lines of code

Best Practices – In Numbers

Less than 400 lines of code

Best Practices – In Numbers

Less than 400 lines of code

Not more than ??? loc / hour

Best Practices – In Numbers

Less than 400 lines of code

Go Slow, not more than 500 loc / hour

Best Practices – In Numbers

Less than 400 lines of code

Go Slow, not more than 500 loc / hour

Maximum of ??? minutes

Best Practices – In Numbers

Less than 400 lines of code

Go Slow, not more than 500 loc / hour

Maximum of 60 minutes

Best Practices – In Numbers

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

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

In a

hurry?

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

Use Tooling - Formatter, Compiler, Metrics, …

– Modern IDE + Extensions

– Continuous Integration

Collect Commits

Practice

Best Practices – Getting Faster

How

How!

Review it yourself

How - Author

How – by Understanding

Review it yourself

Provide Context and Design Rational

– Proposal: 2 Paragraphs in Commit Message

How - Author

Discussion

Review it yourself

Provide Context and Design Rational

– 2 Paragraphs in Commit Message

Embrace Feedback - Give it a thought

How - Author

Generalizing

- Always use this… / Never do that…

+ Can you show me what you mean?

How - Reviewer

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

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?

Conflict

Insist on high quality reviews

-> But agree to disagree

Handle disagreement

How - Conflict

What?

General- and business logic

Architecture and design

Readability and maintainability

Performance

Security

What

General- and business logic

Architecture and design

Readability and maintainability

Performance

Security

What

Checklists

Personal Checklists

What

Checklists

Personal Checklists

Encodo experience

What

What do you

value?

Here

Encodo Code Review Process

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

Foster Strong Review

Culture

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