320 likes | 736 Views
Assignment Each team should perform a code review Select a section of code Select your more difficult code sections. Other members of the team and the instructor will be given copies of the code to review at least 48 hours ahead of time. The code review should last about 1 hour.
E N D
Assignment • Each team should perform a code review • Select a section of code • Select your more difficult code sections. • Other members of the team and the instructor will be given copies of the code to review at least 48 hours ahead of time. • The code review should last about 1 hour. • Don’t select too much code – about 300 lines is good Code Reviews
Find bugs in the least costly manner Ensure that coding standards are maintained Train staff and disseminate knowledge of system implementation Make sure code is readable and maintainable Code Reviews Objectives
All participants are given copies of the code to be reviewed before the review (usually a couple of days ahead of time) The reviewers review the code before the meeting The code author and other team members gather to review the code The principal goal is to find bugs (defects), not fix them Formal Inspection
Moderator • Sets the pace • Arranges meeting and manages materials • Reports Results • Follows up • Author • Answers questions • Explains things that are unclear (and will obviously have to be changed.) Formal Inspections Roles
Reviewer • Fellow programmer • Tester • High-level architect • Scribe • Records problems (the official record of the review) • Records action items • Management must be excluded from the meeting Formal Inspection Roles ContInued
Enough to consume about an hour’s time Number of lines of code varies significantly with code complexity How much Code should Be Reviewed in one Meeting?
Someone other than the moderator or author reads or paraphrases the code • Reviewers make relevant comments as the code is read • Remember you are looking for bugs • Address the code – not the programmer • (“The code does” … rather than “You did…”) • “Egoless” is the goal, but seldom the reality • Reviewers don’t recommend fixes Inspection Meeting
Issued within 24 hours of the meeting • Report is a record of what was found • “What was found” provides statistics for management on efficacy • What was found provides opportunity for follow-up Inspection Report
Rework • The author fixes the defects • Follow-up • The moderator is responsible for seeing that the defects have been addressed, but it is up to the author to make decisions about what needs to be changed. • Review the code again • Review relevant sections only • No formal review Reworks and Follow-up
Optional informal meeting in which reviewers discuss solutions. This meeting should only be held if the author requests it, or if there are significant urgent problems. Third-Hour Meeting
Over-the-shoulder Reviews • Author walks through code with one peer • Less formal • Less documentation/assurance of completion • No formal followup • Email (pass-around) reviews • Not constrained to place/time • Can be difficult to track the conversation • Pair-Programming • Pairs can be too close to the code to see problems • May be more time-consuming/expensive • Can be combined with formal reviews Alternatives