Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared...

48
Creating a Code Review Culture Johnathan Turner @while1malloc0 breaking.computer

Transcript of Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared...

Page 1: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Creating a Code Review Culture

Johnathan [email protected]

Page 2: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Code review is useful

Page 3: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Code review providesa means of ensuring code quality

Page 4: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Code review providesa communication platform

Page 5: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Code review providesan opportunity to teach

Page 6: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

A code review culture is useful

Page 7: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Culture

"the set of shared attitudes, values,

goals, and practices that characterizes an

institution or organization" - Merriam

Webster

Page 8: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Agenda:

Examine the practices that contribute to a

strong code review culture from the

perspective of...

● Organizations

● Authors

● Reviewers

Page 9: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Organizations

Page 10: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Be intentional about your culture

Page 11: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Be intentional about your culture

by communicating the culture

Page 12: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Be intentional about your culture

by establishing a community of experts

Page 13: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Be intentional about your culture

by developing new experts

Page 14: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Be intentional about your culture

by training code reviewers

Page 15: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Code authors

Page 16: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Make the reviewer's life easier

Page 17: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Make the reviewer's life easier

by communicating context

Page 18: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"
Page 19: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Photo courtesy of Julia Evans, @b0rk

Page 20: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"
Page 21: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Make the reviewer's life easier

by making the PR a manageable size

Page 22: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Vertical Slices

● ship the smallest unit of functionality

meaningful to your users

● round trip through your stack

Page 23: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Make the reviewer's life easierby automating the nits

Page 24: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Make the reviewer's life easier

by knowing when to take it offline

Page 25: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Code reviewers

Page 26: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Communicate mutual respect

Page 27: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Communicate mutual respect

by knowing when to take it offline

Page 28: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Communicate mutual respect

by including justification for critique

Page 29: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"
Page 30: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"
Page 31: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Communicate mutual respect

by engaging with the author as an equal

Page 32: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"
Page 33: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"
Page 34: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Communicate mutual respect

by being as thorough as the PR needs

Page 35: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Reviewing in passesEach pass is a theme, and some questions

to help focus on that theme

Page 36: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Reviewing in passesMake your own. Make a checklist.

Page 37: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Passes to complete every time

If there are red flags on any of these, resolve before adding more commentary.

Page 38: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Sizing up

● What is the general shape of the PR?

● Is the PR the right size?

Page 39: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Context

● What is this PR trying to accomplish?

● Why is this PR trying to accomplish

that?

● Does the PR accomplish what it says?

Page 40: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Relevance

● Is the change made in this PR necessary?

● Does this PR duplicate existing

functionality?

● Are there others that should be aware of

this PR?

Page 41: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Passes for more in-depth review

Do these for more substantial PRs. Pick the ones relevant to the change.

Page 42: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Readability

● Is the change reasonably understandable

by other humans with little/no prior

experience of the code?

● Are any esoteric language features being

used?

Page 43: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Production readiness

● How will we know when this breaks?

● Is there new documentation required by

this change?

● Are there tests that prevent regression?

● Is this change secure?

Page 44: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Naming

● Do names communicate what things do?

● Are the names of things idiomatic to the

language?

● Do names leak implementation details?

Page 45: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Gotchas

● What are the ways in which added or

changed code can break?

● Is this code subject to any common

programming gotchas?

● Is spelling correct and consistent?

Page 46: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Language specific

● Is the code well designed?

● Is the code idiomatic to the language?

● Are new patterns introduced?

● Does the code fall into common pitfalls

for the language?

Page 47: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Full checklist at:github.com/while1malloc0/code-review-checklist

Page 48: Culture Creating a Code Review - USENIX...A code review culture is useful Culture "the set of shared attitudes, values, goals, and practices that characterizes an institution or organization"

Thank you

Johnathan [email protected]