Upload
trisha-gee
View
1.196
Download
1
Embed Size (px)
Citation preview
Trisha Gee (@trisha_gee)
Maria Khalusova (@mariaKhalusova)
JetBrains
Code Review Matters and Manners
Matters
What To Look For
• Formatting
• Naming Conventions
• “Final” Keyword
• Line Length
• Empty Statements
• Modifier Order
• Javadoc comments
• ….
Automate these checks
Don’t Sweat the Little Things
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?
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?
Do it in advance, or as you go
Code Review is Too Late For Design
Usability
• UI
• API
Design
• UI
• API
Usability
• Readability
• Maintainability
• Extensibility
Functionality
• Does it do what it’s supposed to?
• Does it meet performance requirements?
• Does it meet security requirements?
• Are there other regulatory requirements?
Decide on priorities, apply consistently
Understand what’s important
Automate these checks
Don’t Sweat the Little Things
Decide on priorities, apply consistently
Understand what’s important
Do it in advance, or as you go
Code Review is Too Late For Design
Don’t Sweat the Little Things
Understand What’s Important
• Functionality
• Does it do what it’s supposed to?
• Does it meet “non-functional” requirements?
• Usability
• Readability
• Maintainability
• Extensibility
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?
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?
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?
Does it do what it’s supposed to?
Is anything wildly wrong with it?
Manners
How to have code review discussions without starting a
war in the comments?
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”
Project Aristotle:
Psychological safety first
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?”
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
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
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.)
There’s a catch :)
“Look at the bullshit you wrote”
“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
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
Trisha Gee (@trisha_gee)
Maria Khalusova (@mariaKhalusova)
JetBrains
Questions?
http://bit.ly/CR-MM/