Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
1
1
Code Review for Busy Teams
A guide for chronically time-poor developers


Brendan Humphreys, Atlassian




               ...
Who am I?
•     @brendanh
• Team Lead, FishEye & Crucible
• 12+ years experience doing code review
• 12+ years of trying t...
Topics
• Back to basics
• How to we got to where we are
• Three steps towards code review
• Strategies & hurdles
• Some ti...
#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)...
What is it that we do all day?




                                 6
7
8
    8
9
Relative cost of fixing a bug

$$$




      Req.    Design   Coding   Testing   QA   Production


                       ...
$500 million
payload
               1 line
               software
               defect
$8 billion
rocket



            ...
12
 12
The Rise of Agile




                    13
14
15
16
17
 17
Machines vs Humans




                     18
blocky:~ brendan$ javac hello.java
hello.java:6: cannot find symbol
symbol : variable length
location: class java.lang.Str...
20
21
Smarter Tools
•Checkstyle, Lint, PMD
•Findbugs
•Clover


                         22
                          22
Continuous Feedback




                      23
                       23
Tougher Questions




                       }
• Meet requirements?
• Architecturally sound?
• Futureproof?             Co...
25
Code Review
• “Systematic review of code by peers”
 • reduce defects
 • spread code ownership
 • mentor developers




   ...
Formal Code Inspection
Fagan, 1976

Finds Defects Early!

Great for mentoring, knowledge sharing

              Printed So...
Pair Programming
            Very effective code review, finds
            defects early
            Great for sharing kno...
Tool-assisted Code Review
•Managed workflow and notification
•Record of discussion
•Asynchronous
•Change team culture?

    ...
3 steps towards a code review
culture
•Make activity visible
•Make code sharable
•Encourage discussions around code


    ...
Making Activity Visible




                          31
FishEye: Unlock your repository




                                  32
                                   32
Making Activity Visible

• The FishEye
  Activity Stream
  • Web
  • RSS
  • Watches
  • JIRA
•                           ...
34
Making Code Sharable

• FishEye makes it easy to share code
  pointers
  • File revisions
  • Source Lines
  • Diffs
  • C...
Encouraging
Discussions
Around code




              36
               36
Crucible: Lightweight Code Review




                                    37
                                     37
Crucible: ChangeSet Discussions



                                  38
                                   38
39
ChangeSet Discussions
• Simple way to provide ad-hoc feedback
• Threaded discussions
• ChangeSet author notified
• Appear i...
Crucible: Snippets



                     41
                      41
42
Snippets
• Simple “paste-bin” service
• Anyone can comment, reply, raise defect
• All participants notified
• Appear in act...
Crucible: “formal” review

• Simple workflow
  • draft, review, summarize, close
• Manage review workload
  • target partic...
45
How to get started

•Go slow
•Just the diffs
•Review the scariest code!
•On demand
•On assignment
                        ...
Common Hurdles to Adoption
• “It takes too much time”
• "Code reviews can get nasty"
• "We have to stick to XYZ process"
•...
Four tips for better reviews




                               48
                                48
#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 errors
   style, catch common
                        coding


 • Look for ...
#3: Find
 Problems,
Not Solutions

                53
#3: Find Problems, Not Solutions

• Except for trivial fixes
• Pair program instead


                                     ...
#4: Embrace Feedback
                       55
#4: Embrace Feedback

• You will learn from it!
• You will learn to love it!



                               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)...
blocky:~ brendan$ ./a.out
On the first day of Christmas my true love gave to me
a partridge in a pear tree.

On the second...
#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)...
60
 60
Upcoming SlideShare
Loading in …5
×

Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010

3,511 views

Published on

Code Review for Teams Too Busy to Review Code

Brendan Humphreys, Atlassian

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010

  1. 1. 1 1
  2. 2. Code Review for Busy Teams A guide for chronically time-poor developers Brendan Humphreys, Atlassian 2 2
  3. 3. Who am I? • @brendanh • Team Lead, FishEye & Crucible • 12+ years experience doing code review • 12+ years of trying to do code review better • 3 3
  4. 4. Topics • Back to basics • How to we got to where we are • Three steps towards code review • Strategies & hurdles • Some tips for better reviews • 4 4
  5. 5. #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 %dn"):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
  6. 6. What is it that we do all day? 6
  7. 7. 7
  8. 8. 8 8
  9. 9. 9
  10. 10. Relative cost of fixing a bug $$$ Req. Design Coding Testing QA Production 10
  11. 11. $500 million payload 1 line software defect $8 billion rocket 11
  12. 12. 12 12
  13. 13. The Rise of Agile 13
  14. 14. 14
  15. 15. 15
  16. 16. 16
  17. 17. 17 17
  18. 18. Machines vs Humans 18
  19. 19. blocky:~ brendan$ javac hello.java hello.java:6: cannot find symbol symbol : variable length location: class java.lang.String for (int i = 0; i < s.length; i++) { ^ 1 error 19
  20. 20. 20
  21. 21. 21
  22. 22. Smarter Tools •Checkstyle, Lint, PMD •Findbugs •Clover 22 22
  23. 23. Continuous Feedback 23 23
  24. 24. Tougher Questions } • Meet requirements? • Architecturally sound? • Futureproof? Code • Coding idioms correct? Review • Potential reuse • Domain knowledge 24 24
  25. 25. 25
  26. 26. Code Review • “Systematic review of code by peers” • reduce defects • spread code ownership • mentor developers 26 26
  27. 27. Formal Code Inspection Fagan, 1976 Finds Defects Early! Great for mentoring, knowledge sharing Printed Source code! Rigid process, Face-to-face meetings! Very slow Impractical for large codebases 27
  28. 28. Pair Programming Very effective code review, finds defects early Great for sharing knowledge, mentoring Requires two developers, co-located Transient discussion Personalities 28
  29. 29. Tool-assisted Code Review •Managed workflow and notification •Record of discussion •Asynchronous •Change team culture? 29 29
  30. 30. 3 steps towards a code review culture •Make activity visible •Make code sharable •Encourage discussions around code 30 30
  31. 31. Making Activity Visible 31
  32. 32. FishEye: Unlock your repository 32 32
  33. 33. Making Activity Visible • The FishEye Activity Stream • Web • RSS • Watches • JIRA • 33 33
  34. 34. 34
  35. 35. Making Code Sharable • FishEye makes it easy to share code pointers • File revisions • Source Lines • Diffs • ChangeSets • 35 35
  36. 36. Encouraging Discussions Around code 36 36
  37. 37. Crucible: Lightweight Code Review 37 37
  38. 38. Crucible: ChangeSet Discussions 38 38
  39. 39. 39
  40. 40. ChangeSet Discussions • Simple way to provide ad-hoc feedback • Threaded discussions • ChangeSet author notified • Appear in Activity Stream • Preserved as annotation to ChangeSet • 40 40
  41. 41. Crucible: Snippets 41 41
  42. 42. 42
  43. 43. Snippets • Simple “paste-bin” service • Anyone can comment, reply, raise defect • All participants notified • Appear in activity stream • Durable, sharable 43 43
  44. 44. Crucible: “formal” review • Simple workflow • draft, review, summarize, close • Manage review workload • target particular reviewers • Advanced features • Pre-commit, Iterative, create from JIRA 44 44
  45. 45. 45
  46. 46. How to get started •Go slow •Just the diffs •Review the scariest code! •On demand •On assignment 46 46
  47. 47. 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" 47 47
  48. 48. Four tips for better reviews 48 48
  49. 49. #1: Strive for Ego-Free Reviews 49
  50. 50. #1: Ego-Free Reviews • No personal Pronouns • No point scoring • Moderator to police 50
  51. 51. #2: Don’t be a Pedant 51
  52. 52. #2: Don’t be a Pedant • Use tools to enforce errors style, catch common coding • Look for the forest, not the trees 52
  53. 53. #3: Find Problems, Not Solutions 53
  54. 54. #3: Find Problems, Not Solutions • Except for trivial fixes • Pair program instead 54
  55. 55. #4: Embrace Feedback 55
  56. 56. #4: Embrace Feedback • You will learn from it! • You will learn to love it! 56
  57. 57. #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 %dn"):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
  58. 58. blocky:~ brendan$ ./a.out On the first day of Christmas my true love gave to me a partridge in a pear tree. On the second day of Christmas my true love gave to me two turtle doves and a partridge in a pear tree. On the third day of Christmas my true love gave to me three french hens, two turtle doves and a partridge in a pear tree. On the fourth day of Christmas my true love gave to me four calling birds, three french hens, two turtle doves and a partridge in a pear tree. On the fifth day of Christmas my true love gave to me five gold rings; four calling birds, three french hens, two turtle doves and a partridge in a pear tree. On the sixth day of Christmas my true love gave to me 58
  59. 59. #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 %dn"):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
  60. 60. 60 60

×