Review your code and all your wildest dreams will come true (vote for Pedro) http://smartbear.com Jason Cohen @ASmartBear StackOverflow Rep: 11,723. Booyah. http://smartbear.com smartbear.com http://smartbear.com Code Collaborator codecollaborator.com http://smartbear.com Peer Code Review != Suck http://smartbear.com http://smartbear.com Act I What’s the Point? http://smartbear.com Requirements Discussion Design Review Architecture Review http://smartbear.com Requirements Discussion Design Review Architecture Review Code (void)0 Where most of the bugs come from http://smartbear.com http://smartbear.com COUNT(editors) > COUNT(writers) http://smartbear.com 9 errors/page http://smartbear.com Spell Czech: Good, butt knot enough http://smartbear.com Common Sense http://smartbear.com The Experiment http://smartbear.com Before Code Review Bugs Remaining in the Application 500 What if we had Peer Review? Bugs Remaining 463 400 Bugs Remaining 321 Rule of Bug: 300 Bugs Remaining 194 200 ? Earlier == Cheaper ? 100 ? 0 After Development After QA/Test ($200/fix) + After Customer ($1000/fix) Cost of fixing bugs: $174k Cost of 194 latent bugs: $194k Total Cost: $368k http://smartbear.com Bugs Remaining in the Application After Code Review 500 Bugs Remaining 463 400 300 Bugs Remaining 180 200 32, down from 194 Bugs Remaining 113 100 Bugs Remaining 32 0 After Development After Code Review ($25/fix) After QA/Test ($200/fix) + After Customer ($1000/fix) Cost of fixing bugs: $120k Cost of 32 latent bugs: $ 32k Total Cost: $152k $152k, down from $368k http://smartbear.com It’s made of people http://smartbear.com The Ego Effect http://smartbear.com Team building http://smartbear.com http://smartbear.com http://smartbear.com http://smartbear.com Team building, for reals http://smartbear.com http://smartbear.com Go faster! http://smartbear.com http://smartbear.com “The problem is, they suck.” http://smartbear.com “Those guys are pretty cool.” http://smartbear.com Specifications Meetings Talking about code http://smartbear.com if(“integrate”.equals( s )) if( 0 == ptr ) http://smartbear.com I’m thiiiiinking of a number… http://smartbear.com if ( youLikeItSoMuch() ) { marryIt(); } http://smartbear.com Hapless Developer Version Control http://smartbear.com Reviewers Peer Code Review != Suck http://smartbear.com Lots of techniques Look over shoulder Auto-email from version control after check-in Walk-through meeting Formal inspection Pair programming http://smartbear.com Act II Best Practices How to not waste time http://smartbear.com Cisco® MeetingPlace® Case Study 3,200,000 lines of code 2,500 reviews 50 developers 10 months San Diego, Bangalore, Budapest http://smartbear.com CodeReviewBook.com http://smartbear.com Defects Found 60-90 minutes max Time (minutes) http://smartbear.com Go slow: 200-500 LOC/hour Defect Density vs. Inspection Rate Defect Density (defects/kLOC) 150 125 100 75 50 25 0 0 200 400 600 800 1000 Review Inspection Rate (LOC/hour) http://smartbear.com 1200 1400 Not too much: 200-400 LOC Defect Density vs. LOC Defect Density (defects/kLOC) 200 150 100 50 0 0 200 400 600 LOC under Review http://smartbear.com 800 1000 Author Preparation is Good! ??? Average Defect Density (Defects/kLOC) Effect of Author Preparation on Defect Density 90 85 80 70 60 50 48 40 30 20 10 0 Without Preparation http://smartbear.com With Prepration Meetings http://smartbear.com Meetings are required. —Michael Fagan, ‘76 http://smartbear.com Fagan Phases 1. Planning 2. Intro 3. Reading 6. Verify 5. Rework 4. Inspect 7. Complete 8. Improve http://smartbear.com = Meeting Meetings are required. —Gilb, Fagan, Wiegers http://smartbear.com You didn’t check for null. —The Phantom Inspector http://smartbear.com Are meetings worth it? —Lawrence Votta, ‘93 http://smartbear.com Defects Found By Inspection Phase Defects from Reading 100 4% Percentage of Total Defects 90 80 70 60 50 40 30 20 10 0 13 Inspection Trials http://smartbear.com Defects from Meeting Checklists http://smartbear.com Checklist for Checklists 7 2 (George Miller, ’52) No obvious stuff Nothing that can be automated Stuff that’s easy to forget EXAMPLE: Errors handled properly everywhere in method http://smartbear.com (Re)building a checklist The Week of Pain http://smartbear.com Act III Just do it. http://smartbear.com Selected Code Stable branch Core module Top 10 scariest files http://smartbear.com Unit tests only http://smartbear.com During feature-freeze http://smartbear.com You know what to do, and you know when to do it. http://smartbear.com Gotta Wanna http://smartbear.com Jason Cohen jason@asmartbear.com http://blog.ASmartBear.com Twit: @asmartbear Code Collaborator http://codecollab.com (Visit our table on your way out!) http://smartbear.com