avi etzioni on code review @outbrain

33
{ Code Quality: Code Review By Avi Etzioni; } Available on Youtube: http ://youtu.be/NeV1tP1IfoM

Upload: avi-etzioni

Post on 19-Jan-2015

137 views

Category:

Technology


0 download

DESCRIPTION

Avi Etzioni talks about the importance of code-review when writing quality code. This tech-talk was given at Outbrain Israel - 31/10/2013. You're also welcome to visit my blog: http://avietzioni.blogspot.co.il/ This is the slides for the presentation on Youtube: http://youtu.be/NeV1tP1IfoM

TRANSCRIPT

Page 1: Avi Etzioni on Code Review @Outbrain

{

Code Quality: Code Review

By Avi Etzioni; }Available on Youtube: http://youtu.be/NeV1tP1IfoM

Page 2: Avi Etzioni on Code Review @Outbrain

Code Quality = #WTF/Min

Page 3: Avi Etzioni on Code Review @Outbrain

Review – not only for code

Students

Politicians

Books

Page 4: Avi Etzioni on Code Review @Outbrain

If only someone reviewed…

Page 5: Avi Etzioni on Code Review @Outbrain

Agenda Part 1 – Code Review – Who needs

it? Feedback Some numbers Why should I seek this feedback? Why should I review others work? Ok, but…

Part 2 – Guidelines for creating and reviewing

Page 6: Avi Etzioni on Code Review @Outbrain

Part 1

Code Review – Who needs it?

Page 7: Avi Etzioni on Code Review @Outbrain
Page 8: Avi Etzioni on Code Review @Outbrain

Design

IDE

Automatic Tests

Build/Integration

Monitor

Take in

Au

toFeed

back

Feedback is all around us

Symptom

Problem

Page 9: Avi Etzioni on Code Review @Outbrain

Some numbers…

Page 10: Avi Etzioni on Code Review @Outbrain

Type of defects found in review

Functional

Non-functional / Maintainability

issues

False positive

Page 11: Avi Etzioni on Code Review @Outbrain

Distribution of defects

71%

21%

7%

MaintainabilityFunctionalFalse positive

Page 12: Avi Etzioni on Code Review @Outbrain

Maintainability Distribution

35%

55%

10%

DocumentationStructureVisual Represen-tation

Page 13: Avi Etzioni on Code Review @Outbrain

Defect Reduction

• Pair Programming: 15%-50%• Unit-Tests: 30%-60%:• Increase in development time: 20%-30%• Does not take into consideration bugs found during the writing of the tests

• Code review meeting: 45%-50%• Asynchronous code-review: 60-65%

Page 14: Avi Etzioni on Code Review @Outbrain

Why should I seek this feedback?

• Enforces better code inspection• Unbiased set of eyes• Find your problems sooner than later• Learn new stuff• Teach the others

Page 15: Avi Etzioni on Code Review @Outbrain

Why should I give this feedback?

• Improve code reading skills• Learn new stuff• Better understanding of the code• Common goal• Let your voice be heard

Page 16: Avi Etzioni on Code Review @Outbrain

What about the organization?

• More capable employees

• Knowledge sharing

• Training for new team

members

• Better quality of the

product

• DISCUSSION

Page 17: Avi Etzioni on Code Review @Outbrain

Ok, but…

Page 18: Avi Etzioni on Code Review @Outbrain

Ok, but… It takes too much time

• What about Design? Graphitus? Take in?• Unit-tests• Who checks them?

• It’s better to favor small reviews• Maintainability issues can make

adding new functionality 28% slower and fixing errors 36% slower *

*Bandi, Vaishnavi, Turk: Predicting Maintenance Performance Using OO Design Complexity metrics

Page 19: Avi Etzioni on Code Review @Outbrain

Ok, but… I’m not familiar with the code

Page 20: Avi Etzioni on Code Review @Outbrain

Ok, but… I’m not familiar with the code

Page 21: Avi Etzioni on Code Review @Outbrain

Ok, but… It’s too subjective

• That’s true, but…• Research shows 82% agreement• Add more reviewers• You don’t have to agree (just be nice about it)

Page 22: Avi Etzioni on Code Review @Outbrain

Ok, but… It’s a minor-change

Page 23: Avi Etzioni on Code Review @Outbrain

Ok, but… I’m a Rockstar

71%

21%

7%

MaintainabilityFunctionalFalse positive

Remember This??

Page 24: Avi Etzioni on Code Review @Outbrain

Part 2

General Guide Lines

Page 25: Avi Etzioni on Code Review @Outbrain

Favor small reviews

• Reviewing a lot of code is a lot to process

• Might intimidate people from starting the review

• Those who start, will probably not finish

• Think of logical ways to split the reviews

Page 26: Avi Etzioni on Code Review @Outbrain

Explain yourself

• What have you done?• High-level explanation• Detailed explanation about non-trivial

changes• Testing Done:• mvn [install ; test ; test –P integration]?• Started the service?• Ran APT?• Simulated tests?

• Next Steps

Page 27: Avi Etzioni on Code Review @Outbrain

Tie your ego to quality… Not to your code

• Comply with standards

… But remember that style is a matter

of taste

• Don’t criticize - advise

• Choose your battles

• Be polite:

• Maybe I don’t understand everything,

but…

• I would prefer...

• Nitpicking: …

Page 28: Avi Etzioni on Code Review @Outbrain

And if you have nothing to say…

• Ship it!

• A good word never hurt anyone

Page 29: Avi Etzioni on Code Review @Outbrain

What to look for???

Page 30: Avi Etzioni on Code Review @Outbrain

Start with searching for the obvious and easy wins

• Typos

• Commented code

• Wrong/missing description

• Trivial exceptions – NPE, OutOfBounds…

• Coding conventions

Page 31: Avi Etzioni on Code Review @Outbrain

And continue with the not so obvious

• Similar (but not exactly duplicated) code

• Project structure

• Affected components / Tests that might

break

• Hidden pitfalls / Bugs

• Security

• ADVANCED LEVEL: patch the code and run

it!

Page 32: Avi Etzioni on Code Review @Outbrain

How to start?

Page 33: Avi Etzioni on Code Review @Outbrain

Thank you!

[email protected]

Twitter: @AviEtzioni