46
Trisha Gee (@trisha_gee) Maria Khalusova (@mariaKhalusova) JetBrains Code Review Matters and Manners

Code Review Matters and Manners

Embed Size (px)

Citation preview

Page 1: Code Review Matters and Manners

Trisha Gee (@trisha_gee)

Maria Khalusova (@mariaKhalusova)

JetBrains

Code Review Matters and Manners

Page 2: Code Review Matters and Manners

Matters

Page 3: Code Review Matters and Manners
Page 4: Code Review Matters and Manners
Page 5: Code Review Matters and Manners
Page 6: Code Review Matters and Manners

What To Look For

• Formatting

• Naming Conventions

• “Final” Keyword

• Line Length

• Empty Statements

• Modifier Order

• Javadoc comments

• ….

Page 7: Code Review Matters and Manners

Automate these checks

Don’t Sweat the Little Things

Page 8: Code Review Matters and Manners

Design: Details

• Is the code in the right place?

• Appropriate data structures used?

• Have opportunities for code re-use been taken?

• Have new dependencies been introduced?

• Is the code making use of existing libraries?

• Is it utilising new idioms?

Page 9: Code Review Matters and Manners

Design: High Level

• Does the new code fit with the overall architecture?

• Does this new code follow the current design practices?

• Have appropriate design patterns been used?

• Does the code follow SOLID principles, Domain Driven Design or other preferred approaches?

• Is the code overly complex or over-engineered?

Page 10: Code Review Matters and Manners

Do it in advance, or as you go

Code Review is Too Late For Design

Page 11: Code Review Matters and Manners

Usability

• UI

• API

Page 12: Code Review Matters and Manners

Design

• UI

• API

Page 13: Code Review Matters and Manners

Usability

• Readability

• Maintainability

• Extensibility

Page 14: Code Review Matters and Manners

Functionality

• Does it do what it’s supposed to?

• Does it meet performance requirements?

• Does it meet security requirements?

• Are there other regulatory requirements?

Page 15: Code Review Matters and Manners

Decide on priorities, apply consistently

Understand what’s important

Page 16: Code Review Matters and Manners
Page 17: Code Review Matters and Manners

Automate these checks

Don’t Sweat the Little Things

Page 18: Code Review Matters and Manners
Page 19: Code Review Matters and Manners
Page 20: Code Review Matters and Manners
Page 21: Code Review Matters and Manners
Page 22: Code Review Matters and Manners

Decide on priorities, apply consistently

Understand what’s important

Page 23: Code Review Matters and Manners
Page 24: Code Review Matters and Manners
Page 25: Code Review Matters and Manners

Do it in advance, or as you go

Code Review is Too Late For Design

Page 26: Code Review Matters and Manners

Don’t Sweat the Little Things

Page 27: Code Review Matters and Manners

Understand What’s Important

• Functionality

• Does it do what it’s supposed to?

• Does it meet “non-functional” requirements?

• Usability

• Readability

• Maintainability

• Extensibility

Page 28: Code Review Matters and Manners

Understand What’s Important

• Is the code in the right place?

• Are the data structures that have been used appropriate?

• Have opportunities for code re-use been taken?

• Is the code overly complex or over-engineered?

• Have new dependencies been introduced?

• Is the code making use of existing libraries?

• Is it utilising new idioms from language updates?

Page 29: Code Review Matters and Manners

Code Review is Too Late for Design

• Is the code in the right place?

• Are the data structures that have been used appropriate?

• Have opportunities for code re-use been taken?

• Is the code overly complex or over-engineered?

• Have new dependencies been introduced?

• Is the code making use of existing libraries?

• Is it utilising new idioms from language updates?

Page 30: Code Review Matters and Manners

Code Review is Too Late for Design

• Does the new code fit with the overall architecture?

• Does this new code follow the current design practices?

• Which design patterns are used in the new code? Are these appropriate?

• Does the code follow SOLID principles, Domain Driven Design etc?

Page 31: Code Review Matters and Manners

Does it do what it’s supposed to?

Page 32: Code Review Matters and Manners

Is anything wildly wrong with it?

Page 33: Code Review Matters and Manners

Manners

Page 34: Code Review Matters and Manners

How to have code review discussions without starting a

war in the comments?

Page 35: Code Review Matters and Manners
Page 36: Code Review Matters and Manners

This happens…

“Instead of touching other people’s code, do something useful with your life”

“Look at the bullshit you wrote”

“The above code is shit, and it generates shit code. It looks bad and there’s no reason for it”

Page 37: Code Review Matters and Manners
Page 38: Code Review Matters and Manners

Project Aristotle:

Psychological safety first

Page 39: Code Review Matters and Manners

It’s not only about being polite…

“Comments must end with a period”

“Something is wrong. I’m not sure what it is. It just doesn’t feel right, you know what I mean?”

Page 40: Code Review Matters and Manners

Why do you leave feedback?

There’s a problem

To help someone improve

To start a discussion

To praise good work

Because of the pressure to find a problem

To boost own ego

Page 41: Code Review Matters and Manners

Basic code review manners

Appropriate timing and place

Indicate when you’re done with a review

Discuss changes, not people

Be specific

Don’t demand, ask questions

Don’t use sarcasm

Suggest alternatives

Page 42: Code Review Matters and Manners

A few tips on wording

Don’t be rude.

“WTF is this?” “That’s a dumb idea…”

Who, What, Where, How, And Why?

“This will not work if…” vs “What happens if..?”

Avoid using “obviously”, “simply”, “just”

Avoid possessive adjectives

“Your method returns…” vs “This method returns…”

Never say never (and “always”, “nothing”, etc.)

Page 43: Code Review Matters and Manners

There’s a catch :)

“Look at the bullshit you wrote”

Page 44: Code Review Matters and Manners

“A fool thinks himself to be wise, but a wise man knows himself to be a fool.”

William Shakespeare

“Everyone you will ever meet knows something you don't.”

Bill Nighy

Page 45: Code Review Matters and Manners

Receiving feedback

Invite teammates to review your code

Separate criticism from self

Immediate reaction isn’t always the best one

Ask questions

Be grateful for the feedback

Page 46: Code Review Matters and Manners

Trisha Gee (@trisha_gee)

Maria Khalusova (@mariaKhalusova)

JetBrains

Questions?

http://bit.ly/CR-MM/