Code Inspections & Walkthroughs
Code inspections and walkthroughs are structured peer review techniques that help find defects early. They are among the most effective quality assurance techniques, often finding 60-90% of defects before testing begins.
Types of Code Reviews
+---------------------------------------------------------+
| CODE REVIEW TYPES |
+---------------------------------------------------------+
| |
| WALKTHROUGH |
| - Informal presentation by the author |
| - Purpose: share knowledge, get feedback |
| - No formal roles or checklist |
| |
| TECHNICAL REVIEW |
| - Focused on technical content |
| - Led by a technical lead |
| - Examines design and implementation |
| |
| FORMAL INSPECTION (Fagan Inspection) |
| - Most formal and rigorous |
| - Defined roles: moderator, author, reader, recorder |
| - Uses checklists and defect logging |
| - Finds defects through systematic examination |
| |
| PEER REVIEW |
| - Informal review by colleagues |
| - Common in modern agile teams |
| - Often done via pull requests |
| |
+---------------------------------------------------------+
Fagan Inspection Steps
1. PLANNING
- Moderator selects team and distributes materials
- Code is assigned for review
2. OVERVIEW
- Author presents the code and design decisions
- Questions are answered
3. PREPARATION
- Each reviewer studies the code independently
- Uses checklists to guide examination
4. INSPECTION MEETING
- Reader (not author) walks through the code line by line
- Recorder logs all defects found
- Discussion focuses on finding issues, not fixing them
5. Rework
- Author fixes all logged defects
6. Follow-up
- Moderator verifies all defects are addressed
Review Checklists
- Does the code follow coding standards?
- Are there any logic errors or edge cases missed?
- Is error handling appropriate?
- Are variable names clear and meaningful?
- Is the code well-documented where needed?
- Are there any security vulnerabilities?
Key Takeaways
- Code reviews find defects earlier and cheaper than testing
- Formal inspections are most effective for critical code
- Walkthroughs and peer reviews share knowledge across the team
- Always use checklists to ensure consistency