code review for teams too busy to review code - atlassian summit 2010
Post on 21-Oct-2014
2.852 views
DESCRIPTION
Code Review for Teams Too Busy to Review Code Brendan Humphreys, AtlassianTRANSCRIPT
![Page 1: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/1.jpg)
11
![Page 2: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/2.jpg)
A guide for chronically time-poor developers
Code Review for Busy Teams
Brendan Humphreys, Atlassian
22
![Page 3: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/3.jpg)
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
![Page 4: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/4.jpg)
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
![Page 5: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/5.jpg)
#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
![Page 6: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/6.jpg)
What is it that we do all day?
6
![Page 7: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/7.jpg)
7
![Page 8: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/8.jpg)
88
![Page 9: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/9.jpg)
9
![Page 10: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/10.jpg)
Req. Design Coding Testing QA Production
$$$
Relative cost of fixing a bug
10
![Page 11: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/11.jpg)
$500 million payload
$8 billionrocket
1 line softwaredefect
11
![Page 12: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/12.jpg)
1212
![Page 13: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/13.jpg)
The Rise of Agile
13
![Page 14: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/14.jpg)
14
![Page 15: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/15.jpg)
15
![Page 16: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/16.jpg)
16
![Page 17: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/17.jpg)
1717
![Page 18: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/18.jpg)
Machines vs Humans
18
![Page 19: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/19.jpg)
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
![Page 20: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/20.jpg)
20
![Page 21: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/21.jpg)
21
![Page 22: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/22.jpg)
•Checkstyle, Lint, PMD•Findbugs•Clover
22
Smarter Tools
22
![Page 23: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/23.jpg)
Continuous Feedback
2323
![Page 24: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/24.jpg)
Tougher Questions
•Meet requirements? •Architecturally sound?•Futureproof?•Coding idioms correct?•Potential reuse•Domain knowledge
24
CodeReview}
24
![Page 25: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/25.jpg)
25
![Page 26: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/26.jpg)
Code Review
•“Systematic review of code by peers”• reduce defects• spread code ownership• mentor developers
2626
![Page 27: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/27.jpg)
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
![Page 28: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/28.jpg)
Very effective code review, finds defects early
Great for sharing knowledge,mentoring
Pair Programming
Requires two developers,co-located
Transient discussionPersonalities
28
![Page 29: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/29.jpg)
Tool-assisted Code Review
29
•Managed workflow and notification•Record of discussion•Asynchronous•Change team culture?
29
![Page 30: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/30.jpg)
3 steps towards a code review culture
30
•Make activity visible•Make code sharable•Encourage discussions around code
30
![Page 31: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/31.jpg)
Making Activity Visible
31
![Page 32: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/32.jpg)
FishEye: Unlock your repository
3232
![Page 33: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/33.jpg)
Making Activity Visible
33
•The FishEyeActivity Stream•Web•RSS•Watches• JIRA•
33
![Page 34: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/34.jpg)
34
![Page 35: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/35.jpg)
Making Code Sharable
35
•FishEye makes it easy to share code pointers•File revisions•Source Lines•Diffs•ChangeSets•
35
![Page 36: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/36.jpg)
EncouragingDiscussionsAround code
3636
![Page 37: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/37.jpg)
Crucible: Lightweight Code Review
3737
![Page 38: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/38.jpg)
Crucible: ChangeSet Discussions
3838
![Page 39: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/39.jpg)
39
![Page 40: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/40.jpg)
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
![Page 41: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/41.jpg)
Crucible: Snippets
4141
![Page 42: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/42.jpg)
42
![Page 43: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/43.jpg)
Snippets•Simple “paste-bin” service•Anyone can comment, reply, raise defect•All participants notified•Appear in activity stream•Durable, sharable
4343
![Page 44: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/44.jpg)
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
![Page 45: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/45.jpg)
45
![Page 46: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/46.jpg)
How to get started
•Go slow•Just the diffs•Review the scariest code!•On demand•On assignment
4646
![Page 47: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/47.jpg)
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
![Page 48: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/48.jpg)
Four tips for better reviews
4848
![Page 49: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/49.jpg)
#1:Strive for Ego-Free Reviews
49
![Page 50: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/50.jpg)
#1: Ego-Free Reviews
• No personal Pronouns
• No point scoring
• Moderator to police
50
![Page 51: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/51.jpg)
#2:Don’t be a
Pedant
51
![Page 52: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/52.jpg)
#2: Don’t be a Pedant
•Use tools to enforce coding style, catch common errors
•Look for the forest, not the trees
52
![Page 53: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/53.jpg)
#3: Find Problems,
Not Solutions
53
![Page 54: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/54.jpg)
#3: Find Problems, Not Solutions
• Except for trivial fixes
• Pair program instead
54
![Page 55: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/55.jpg)
#4: Embrace Feedback55
![Page 56: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/56.jpg)
•You will learn from it!
•You will learn to love it!
#4: Embrace Feedback
56
![Page 57: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/57.jpg)
#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
![Page 58: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/58.jpg)
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
![Page 59: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/59.jpg)
#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
![Page 60: Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010](https://reader034.vdocuments.mx/reader034/viewer/2022052617/544648c5b1af9ff83a8b45ba/html5/thumbnails/60.jpg)
6060