Top Banner
Code Review May 2015 @hakansaglam
52
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Voxxed days 2015-hakansaglam-codereview

Code Review

May 2015

@hakansaglam

Page 2: Voxxed days 2015-hakansaglam-codereview

Hakan Saglam

developing since 2000doing code review since 2004

software developer @ havelsanlead software developer @ oytek

project manager @ software agtechnical coordinator @ sony

solution architect @ sony

head of mobile development @ peak games

Page 3: Voxxed days 2015-hakansaglam-codereview

THE USUAL SUSPECTS

by Matt Owen

Page 4: Voxxed days 2015-hakansaglam-codereview

What is code review?

Page 5: Voxxed days 2015-hakansaglam-codereview

It is intended to find and fix mistakes overlooked in the initial development phase,

improving both the overall quality of software and the developers' skills.

CODE INSPECTION

INTRODUCED BY MICHAEL FAGAN IN 1976

Page 6: Voxxed days 2015-hakansaglam-codereview

CODE TEST

Page 7: Voxxed days 2015-hakansaglam-codereview

CODE TESTREVIEW

Page 8: Voxxed days 2015-hakansaglam-codereview

The reviewer

and the

author are a

team

Page 9: Voxxed days 2015-hakansaglam-codereview

Why should we do code review?

Page 10: Voxxed days 2015-hakansaglam-codereview

one hour of inspection

20 hours of testing

82 hours rework

Each hour of inspection saved 20 hours of testing and 82 hours of rework effort had the defects found by

inspection remained in the released products.

Page 11: Voxxed days 2015-hakansaglam-codereview

If we do review at the earlier stage, the cost to fix this will be

less. It is 2400% cheaper to fix any issues in development

stage than in the production environment.

http://www.kunal-chowdhury.com/2013/06/code-review-and-its-importance.html

http://www.veracode.com/blog/2015/03/how-code-review-best-practices-saved-one-company-millions

Page 12: Voxxed days 2015-hakansaglam-codereview
Page 13: Voxxed days 2015-hakansaglam-codereview

IS IT ALL ABOUT BUGS?

BEYOND THAT DEFINITION

Page 14: Voxxed days 2015-hakansaglam-codereview

DISCUSSIONS

COMMITDISCUSS

DISCUSS

DISCUSSCOMMIT

MERGEhttps://flic.kr/p/fHgQDg

COMMIT DISCUSS

Page 15: Voxxed days 2015-hakansaglam-codereview

CULTURE

Every Code Review is an opportunity to learn and teach. And a very simple way to build

an engineering culture.https://flic.kr/p/89YLs1

Page 16: Voxxed days 2015-hakansaglam-codereview

Who should make code review?

Page 17: Voxxed days 2015-hakansaglam-codereview

ALL TEAM

Team Leader

Junior Developer

Senior Developer

SolutionArchitect

TechnicalSpecialist

https://flic.kr/p/9XdG3M

Page 18: Voxxed days 2015-hakansaglam-codereview

The social incentives inherent in voluntary code review policies

encourage developers to take ownership of the code.

AUTONOMY

http://alysonschafer.com/wp-content/uploads/2014/08/autonomy_makes_children_more_responsible.jpg

Page 19: Voxxed days 2015-hakansaglam-codereview

How should we do code review?

Page 20: Voxxed days 2015-hakansaglam-codereview

CODE REVIEW

WAS HARD

Page 21: Voxxed days 2015-hakansaglam-codereview

1 CODEREVIEW

viaTOOLS

Page 22: Voxxed days 2015-hakansaglam-codereview

BREAK TASKS INTO

SMALLERPIECES

https://flic.kr/p/bBZMoJ

team

Page 23: Voxxed days 2015-hakansaglam-codereview

DEFINITION OF DONE

An agreed team definition of done is essential to produce

high quality code.

teamhttps://flic.kr/p/8oXJWd

Page 24: Voxxed days 2015-hakansaglam-codereview

http://www.slideshare.net/lemiorhan/fix-your-broken-windows-with-code-review-phpist14

Reorder commits with rebaseto make the review easier.

author

Page 25: Voxxed days 2015-hakansaglam-codereview

RUBBER DUCK

DEBUGGINGhttps://flic.kr/p/39jEVr

author

Page 26: Voxxed days 2015-hakansaglam-codereview

author

Page 27: Voxxed days 2015-hakansaglam-codereview

LET’S DOCODE

REVIEWInstead of finding your own solution, try to understand author’s solution.

https://flic.kr/p/4eLyGdreviewer

Page 28: Voxxed days 2015-hakansaglam-codereview

MASLOW PYRAMID OF CODE REVIEW

CORRECTSECURE READABLE

ELEGANTALTURIST

reviewer

http://blog.d3in.org/post/111338685456/maslows-pyramid-of-code-review

Page 29: Voxxed days 2015-hakansaglam-codereview

CORRECT

•  Does the code do what it’s supposed to? •  Does it handle edge cases? •  Is it adequately tested to make sure that it stays correct? •  Is it performant enough for this use case?

reviewer

Page 30: Voxxed days 2015-hakansaglam-codereview

SECURE

•  Does the code have vulnerabilities?•  Is the data stored safely? •  Is personal identification information handled correctly? •  Could the code be used to induce a DOS? •  Is input validation comprehensive enough?

reviewer

Page 31: Voxxed days 2015-hakansaglam-codereview

READABLE

•  Is the code easy to read and comprehend? •  Does it make clear what the business requirements are?•  Are variables, functions and classes named appropriately? •  Does it use consistent coding convention?

reviewer

Page 32: Voxxed days 2015-hakansaglam-codereview

ELEGANT

•  Does the code leverage well-known patterns? •  Does it achieve what it needs to do without sacrificing

simplicity and conciseness?•  Does the code reuse existing functions when applicable?•  Would you be proud of this code?

reviewer

Page 33: Voxxed days 2015-hakansaglam-codereview

ALTURIST

•  Does the code leave the codebase better than what it was?

•  Does it inspire other engineers to improve their code? •  Is it cleaning up unused code?•  Is it improving documentation, introducing better patterns

through small-scale refactoring?

reviewer

Page 34: Voxxed days 2015-hakansaglam-codereview

reviewer

CHECKLIST

Develop your own domain and language specific checklist both for better review and

better coding.

Page 35: Voxxed days 2015-hakansaglam-codereview

reviewer

author

GIVE FEEDBACK

FEEDBACK EMBRACE

FEEDBACK FEEDBACK

https://flic.kr/p/baYdD4

Page 36: Voxxed days 2015-hakansaglam-codereview

authorreviewer

WATCHyourWORDS

LEAVEyour

EGOhttps://flic.kr/p/kr98Fr

Page 37: Voxxed days 2015-hakansaglam-codereview

https://flic.kr/p/7JAXE4

IMPLEMENTAGREED

CHANGES

author

Page 38: Voxxed days 2015-hakansaglam-codereview

MERGEPULL REQUEST

reviewerhttp://www.inc.com/uploaded_files/image/how-to-merge-corporate-culutres-pop_8709.jpg

Page 39: Voxxed days 2015-hakansaglam-codereview

https://www.previousnext.com.au/blog/automated-drupal-testing-github-pull-requests

CODEREVIEWviaTOOLS

RECAP

Page 40: Voxxed days 2015-hakansaglam-codereview

TWO DEVELOPER ONE MACHINE

https://flic.kr/p/84RfxX

PAIR PROGRAMMING

2

Page 41: Voxxed days 2015-hakansaglam-codereview

pair

SOME TASKS

NEEDS TO BE COMPLETED

IN ONE BLOCK

OF TIME

http://groundedpsyche.com/wp-content/uploads/2015/01/Iceberg.png

Page 42: Voxxed days 2015-hakansaglam-codereview

THINGS CAN HAPPEN

pair

THAT ARE NOTPART OF THE PLAN

https://flic.kr/p/fq4RiW

Page 43: Voxxed days 2015-hakansaglam-codereview

ONBOARDYOURNEW COMERS

pairhttps://flic.kr/p/5hbe4x

Page 44: Voxxed days 2015-hakansaglam-codereview

SOME-TIMESYOU JUSTNEED HELP

pair

Page 45: Voxxed days 2015-hakansaglam-codereview

TEAM REVIEW

3 LET’S GETTOGETHER

Page 46: Voxxed days 2015-hakansaglam-codereview

team

GETTING READY FOR NEW

TECHNOLOGIEShttp://www.kaizen-news.com/wp-content/uploads/2014/02/5s-ingrediants.jpg

Page 47: Voxxed days 2015-hakansaglam-codereview

team POST PROJECT REVIEWS

(a.k.a.) AFTER PARTY

CLEANINGhttps://flic.kr/p/2PVtrp

Page 48: Voxxed days 2015-hakansaglam-codereview

TO MAKE THE RIGHT MOVES

team

SOFTWARE ENGINEERING PRINCIPALS

https://flic.kr/p/4hLh9S

Page 49: Voxxed days 2015-hakansaglam-codereview

CODE REVIEWPRACTICES

PULL REQUESTSPAIR PROGRAMMING

TEAM REVIEW

RECAP

Page 50: Voxxed days 2015-hakansaglam-codereview

What is code review?Why it is needed?Who should make review?

How we can do it with tools?How we can do it in pairs?How we can do it as team?

Page 51: Voxxed days 2015-hakansaglam-codereview

Make peace with the simple fact that the code you’re shipping

today has bugs.

Make peace that your work is never done.

https://flic.kr/p/8ZxReChttp://www.pushing-pixels.org/2015/04/15/make-peace.html

Page 52: Voxxed days 2015-hakansaglam-codereview

@hakansaglam