Effective Code Reviews

35
code-quality.de @FrankS Effective Code Reviews

Transcript of Effective Code Reviews

Page 1: Effective Code Reviews

code-quality.de @FrankS

Effective Code Reviews

Page 2: Effective Code Reviews

Moin moin!

Frank SonsFrank Sons FrankS FrankS

http://code-quality.dehttp://code-quality.de

Page 3: Effective Code Reviews

code-quality.de @FrankS

Please!

Feel free to ask questions!Feel free to ask questions!

And share your own experiences!And share your own experiences!

Page 4: Effective Code Reviews

code-quality.de @FrankS

My list for today...

The bigger picture of code reviewsThe bigger picture of code reviews

Improving your code reviewsImproving your code reviews

Page 5: Effective Code Reviews

code-quality.de @FrankS

Let's start with the basics...

The two ways of code reviewsThe two ways of code reviews

Expectations vs. The real worldExpectations vs. The real world

A well hidden problemA well hidden problem

Page 6: Effective Code Reviews

code-quality.de @FrankS

Are you doing code reviews?

Page 7: Effective Code Reviews

code-quality.de @FrankS

Review tools - asynchronous

Page 8: Effective Code Reviews

code-quality.de @FrankS

Code reviews as a team

Page 9: Effective Code Reviews

code-quality.de @FrankS

Bigger screen helps ;-)

Page 10: Effective Code Reviews

code-quality.de @FrankS

Let's take a look at the motivation

The two ways of code reviewsThe two ways of code reviews

Expectations vs. The real worldExpectations vs. The real world

A well hidden problemA well hidden problem

Page 11: Effective Code Reviews

code-quality.de @FrankS

Why are you doing code reviews?

Page 12: Effective Code Reviews

code-quality.de @FrankS

Motivation for code reviews (study)

Page 13: Effective Code Reviews

code-quality.de @FrankS

The results are a bit surprising

Page 14: Effective Code Reviews

code-quality.de @FrankS

There is something else...

The two ways of code reviewsThe two ways of code reviews

Expectations vs. The real worldExpectations vs. The real world

A well hidden problemA well hidden problem

Page 15: Effective Code Reviews

code-quality.de @FrankS

Does this sound familiar?

Not structured and no real goalsNot structured and no real goals

It's working fine (somehow...)It's working fine (somehow...)

Favorite reviewersFavorite reviewers

Page 16: Effective Code Reviews

code-quality.de @FrankS

The main problem:

Results depend on experience, timing andmotivation of the reviewing developer!

Results depend on experience, timing andmotivation of the reviewing developer!

Page 17: Effective Code Reviews

code-quality.de @FrankS

Well...

Page 18: Effective Code Reviews

code-quality.de @FrankS

Let's see what we can do!

The bigger picture of code reviewsThe bigger picture of code reviews

Improving your code reviewsImproving your code reviews

Page 19: Effective Code Reviews

code-quality.de @FrankS

Forget about the tools for a moment

Establishing a common mindsetEstablishing a common mindset

Setting the right focusSetting the right focus

Creating a checklistCreating a checklist

Page 20: Effective Code Reviews

code-quality.de @FrankS

Code reviews meetings are a good start

Assign moderator and readerAssign moderator and reader

The goal is not to cover all codeThe goal is not to cover all code

Create a shared understanding a code qualityCreate a shared understanding a code quality

Page 21: Effective Code Reviews

code-quality.de @FrankS

The reader explains the code...

Page 22: Effective Code Reviews

code-quality.de @FrankS

A moderator can help a lot!

Page 23: Effective Code Reviews

code-quality.de @FrankS

Be sure to focus on the important parts

Establishing a mindsetEstablishing a mindset

Setting the right focusSetting the right focus

Creating a checklistCreating a checklist

Page 24: Effective Code Reviews

code-quality.de @FrankS

What do you check?

Code quality metricsCode quality metrics

Code improvements and understandingCode improvements and understanding

Page 25: Effective Code Reviews

code-quality.de @FrankS

Do you have to understand the code?

Page 26: Effective Code Reviews

code-quality.de @FrankS

Readability and Understanding

„You can only find defects,if you are able to understand the code!“

„You can only find defects,if you are able to understand the code!“

Page 27: Effective Code Reviews

code-quality.de @FrankS

A small, but important difference!

Coding Style GuideCoding Style Guide

Coding GuidelineCoding Guideline

Page 28: Effective Code Reviews

code-quality.de @FrankS

Do you have guidelines?

Page 29: Effective Code Reviews

code-quality.de @FrankS

So, what should you put in a guideline?

Anything that can not be validated automatically!Anything that can not be validated automatically!

Page 30: Effective Code Reviews

code-quality.de @FrankS

Guidelines make a good start

Establishing a mindsetEstablishing a mindset

Setting the right focusSetting the right focus

Creating a checklistCreating a checklist

Page 31: Effective Code Reviews

code-quality.de @FrankS

Create a checklist for your reviews

Page 32: Effective Code Reviews

code-quality.de @FrankS

Checklists improve your reviews

Reviewers know what they are looking forReviewers know what they are looking for

Does not depend on that much luck anymoreDoes not depend on that much luck anymore

Always keep them updated!Always keep them updated!

Page 33: Effective Code Reviews

code-quality.de @FrankS

Make sure you do code reviews – effectively!

„Peer code reviews are the single biggestthing you can do to improve your code.“„Peer code reviews are the single biggestthing you can do to improve your code.“

Jeff Atwood – @codinghorror

Page 34: Effective Code Reviews

code-quality.de @FrankS

Some final things to keep in mind

Make sure everyone knows the real goalsMake sure everyone knows the real goals

Establish a common mindset for code qualityEstablish a common mindset for code quality

Code reviews need to be part of your processCode reviews need to be part of your process

Page 35: Effective Code Reviews

code-quality.de @FrankS

Questions? Feedback?