code review for teams too busy to review code - atlassian summit 2010

Post on 21-Oct-2014

2.846 Views

Category:

Technology

2 Downloads

Preview:

Click to see full reader

DESCRIPTION

Code Review for Teams Too Busy to Review Code Brendan Humphreys, Atlassian

TRANSCRIPT

11

A guide for chronically time-poor developers

Code Review for Busy Teams

Brendan Humphreys, Atlassian

22

Who am I?

3

• @brendanh•Team Lead, FishEye & Crucible•12+ years experience doing code review•12+ years of trying to do code review better•

3

Topics

•Back to basics•How to we got to where we are•Three steps towards code review•Strategies & hurdles•Some tips for better reviews•

44

#include <stdio.h>main(t,_,a)char *a;{return!0<t?t<3?main(-79,-13,a+main(-87,1-_,main(-86,0,a+1)+a)):1,t<_?main(t+1,_,a):3,main(-94,-27+t,a)&&t==2?_<13?main(2,_+1,"%s %d %d\n"):9:16:t<0?t<-72?main(_,t,"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l,+,/n{n+,/+#n+,/#\;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l \q#'+d'K#!/+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# \){nl]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#n'wk nw' \iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c \;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;#'rdq#w! nr'/ ') }+}{rl#'{n' ')# \}'+}##(!!/"):t<-50?_==*a?putchar(31[a]):main(-65,_,a+1):main((*a=='/')+t,_,a+1) :0<t?main(2,2,"%s"):*a=='/'||main(0,main(-61,*a,"!ek;dc i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);}

5

What is it that we do all day?

6

7

88

9

Req. Design Coding Testing QA Production

$$$

Relative cost of fixing a bug

10

$500 million payload

$8 billionrocket

1 line softwaredefect

11

1212

The Rise of Agile

13

14

15

16

1717

Machines vs Humans

18

blocky:~ brendan$ javac hello.java hello.java:6: cannot find symbolsymbol : variable lengthlocation: class java.lang.String for (int i = 0; i < s.length; i++) { ^1 error

19

20

21

•Checkstyle, Lint, PMD•Findbugs•Clover

22

Smarter Tools

22

Continuous Feedback

2323

Tougher Questions

•Meet requirements? •Architecturally sound?•Futureproof?•Coding idioms correct?•Potential reuse•Domain knowledge

24

CodeReview}

24

25

Code Review

•“Systematic review of code by peers”• reduce defects• spread code ownership• mentor developers

2626

Formal Code InspectionFagan, 1976

Finds Defects Early!

Printed Source code!

Rigid process,Face-to-face meetings!

Very slowImpractical for largecodebases

Great for mentoring, knowledge sharing

27

Very effective code review, finds defects early

Great for sharing knowledge,mentoring

Pair Programming

Requires two developers,co-located

Transient discussionPersonalities

28

Tool-assisted Code Review

29

•Managed workflow and notification•Record of discussion•Asynchronous•Change team culture?

29

3 steps towards a code review culture

30

•Make activity visible•Make code sharable•Encourage discussions around code

30

Making Activity Visible

31

FishEye: Unlock your repository

3232

Making Activity Visible

33

•The FishEyeActivity Stream•Web•RSS•Watches• JIRA•

33

34

Making Code Sharable

35

•FishEye makes it easy to share code pointers•File revisions•Source Lines•Diffs•ChangeSets•

35

EncouragingDiscussionsAround code

3636

Crucible: Lightweight Code Review

3737

Crucible: ChangeSet Discussions

3838

39

ChangeSet Discussions

40

•Simple way to provide ad-hoc feedback•Threaded discussions•ChangeSet author notified•Appear in Activity Stream•Preserved as annotation to ChangeSet•

40

Crucible: Snippets

4141

42

Snippets•Simple “paste-bin” service•Anyone can comment, reply, raise defect•All participants notified•Appear in activity stream•Durable, sharable

4343

Crucible: “formal” review

44

•Simple workflow• draft, review, summarize, close•Manage review workload• target particular reviewers•Advanced features• Pre-commit, Iterative, create from JIRA

44

45

How to get started

•Go slow•Just the diffs•Review the scariest code!•On demand•On assignment

4646

Common Hurdles to Adoption

•“It takes too much time”•"Code reviews can get nasty"•"We have to stick to XYZ process"•"I don't want to leave my IDE"

4747

Four tips for better reviews

4848

#1:Strive for Ego-Free Reviews

49

#1: Ego-Free Reviews

• No personal Pronouns

• No point scoring

• Moderator to police

50

#2:Don’t be a

Pedant

51

#2: Don’t be a Pedant

•Use tools to enforce coding style, catch common errors

•Look for the forest, not the trees

52

#3: Find Problems,

Not Solutions

53

#3: Find Problems, Not Solutions

• Except for trivial fixes

• Pair program instead

54

#4: Embrace Feedback55

•You will learn from it!

•You will learn to love it!

#4: Embrace Feedback

56

#include <stdio.h>main(t,_,a)char *a;{return!0<t?t<3?main(-79,-13,a+main(-87,1-_,main(-86,0,a+1)+a)):1,t<_?main(t+1,_,a):3,main(-94,-27+t,a)&&t==2?_<13?main(2,_+1,"%s %d %d\n"):9:16:t<0?t<-72?main(_,t,"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l,+,/n{n+,/+#n+,/#\;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l \q#'+d'K#!/+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# \){nl]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#n'wk nw' \iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c \;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;#'rdq#w! nr'/ ') }+}{rl#'{n' ')# \}'+}##(!!/"):t<-50?_==*a?putchar(31[a]):main(-65,_,a+1):main((*a=='/')+t,_,a+1) :0<t?main(2,2,"%s"):*a=='/'||main(0,main(-61,*a,"!ek;dc i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);}

57

blocky:~ brendan$ ./a.outOn the first day of Christmas my true love gave to mea partridge in a pear tree.

On the second day of Christmas my true love gave to metwo turtle dovesand a partridge in a pear tree.

On the third day of Christmas my true love gave to methree french hens, two turtle dovesand a partridge in a pear tree.

On the fourth day of Christmas my true love gave to mefour calling birds, three french hens, two turtle dovesand a partridge in a pear tree.

On the fifth day of Christmas my true love gave to mefive gold rings;four calling birds, three french hens, two turtle dovesand a partridge in a pear tree.

On the sixth day of Christmas my true love gave to mesix geese a-laying, five gold rings;four calling birds, three french hens, two turtle dovesand a partridge in a pear tree.

On the seventh day of Christmas my true love gave to meseven swans a-swimming,six geese a-laying, five gold rings;four calling birds, three french hens, two turtle dovesand a partridge in a pear tree.

On the eighth day of Christmas my true love gave to meeight maids a-milking, seven swans a-swimming,six geese a-laying, five gold rings;four calling birds, three french hens, two turtle dovesand a partridge in a pear tree.

58

#include <stdio.h>main(t,_,a)char *a;{return!0<t?t<3?main(-79,-13,a+main(-87,1-_,main(-86,0,a+1)+a)):1,t<_?main(t+1,_,a):3,main(-94,-27+t,a)&&t==2?_<13?main(2,_+1,"%s %d %d\n"):9:16:t<0?t<-72?main(_,t,"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l,+,/n{n+,/+#n+,/#\;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l \q#'+d'K#!/+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# \){nl]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#n'wk nw' \iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c \;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;#'rdq#w! nr'/ ') }+}{rl#'{n' ')# \}'+}##(!!/"):t<-50?_==*a?putchar(31[a]):main(-65,_,a+1):main((*a=='/')+t,_,a+1) :0<t?main(2,2,"%s"):*a=='/'||main(0,main(-61,*a,"!ek;dc i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);}

59

6060

top related