How to Conduct Effective Code Reviews


Good Programming Practices –

How to Conduct Effective Code Reviews


Why Code reviews
For Code quality
l          Tend to improve the overall code structure and there by aid maintainability.
l          Promote refactoring which improves code re-use.
l          Improve the code to handle the corner cases.
l          Improve the test cases and there by improve test coverage.
l          Fix critical and rare defects - most of the multi-threading and concurrent access bugs tend to fall into this category.
For Team, Developers
l          Developers know their code will be evaluated, so they work harder.
l          It creates consistency and a culture of quality across the project.
l          Spread knowledge in team.
l          Improve team members’ skills.
l          Improve team morale.
Code Review Process
Preparation
Take advantage of static code analysis tools - such as Find Bugs, PMD, Google CodePro AnalytiX. It's responsibility of the developer who write the code or fix to take advantage of static code analysis tools to audit his/her code first to check and avoid common mistakes.
These tools will effectively save a lot of time/tedium for the team, so the team can focus on more interesting and challenging tasks.
Agenda & Scope
Before code review, one mediator should be response for collecting meeting agenda and scope and notifying other team members, including the code to be reviewed etc.
The mediator is not necessary to be the team leader; all team members can take turns to host the review meeting.

The scope should include the code being reviewed and it should address if there is any special emphasis - like performance, security etc.
Taking notes to team knowledge database- Lesson Learned and Action items
Code review is an intense activity. Lot of ideas are generated and discussed, new subtle/complicated bug may be discovered.
Code review is also a learning opportunity to improve team skills, to learn from the outcome, to learn from the mistakes we have made. These are valued asset for the team.

So the mediator should be response for taking notes to team knowledge database such team wiki, team blog etc. Anything that is useful and important to the team can be recorded, such as mistakes we made, ways we diagnoses the defect, alternative solution to the problem etc.
He should also be response for capturing important ones as action items and follow up.
Follow up

To gain adequate benefit of the code reviews, the team has to allocate sufficient time or resources to follow up the issues raised by the code review.
How to Conduct Effective Code Reviews
Make code reviews a learning opportunity.
Build the culture of knowledge sharing in your team
Spread knowledge and love.
l          The most important thing to conduct effective code review is to motivate team members to be engaged in code review actively.
l          Good team atmosphere, good relationship between colleagues is the key.
l          Let team members know the benefits of code review, for the team, for improving code quality, and especially for themselves.
Actually read the code.
A good code review always goes beyond the obvious
The coder should create a checklist of the things that the code reviews tend to focus on.
Check the document and comment.
l          If the code is complicated and doesn't explain itself, ensure it is well commented.
Make sure you have good coding standards to reference.
Matters needing attention
Remember to praise.
Ask questions rather than make statements.  
Make sure the discussion stays focused on the code and not the coder.
Remember that there is often more than one way to approach a solution.

What to talk about the code?
To let others know the code easily, we should not only explain the code itself, but also explain why we implement the code this way.

For bug fix, we should explain the root cause of the bug, and convince others the RCA.
If the bug is really hard and subtle, and we made great efforts to find it out, we may also cover how we diagnose it, and how we find out the RCA.

This is not related with code review, but is the way to spread and share knowledge in the team.
This is also a way to show you how hard you work on this defect.

But of course, how much we can talk about the code depends on review meeting schedule.

Resources:
Effective Code Reviews
Effective Code Reviews Without the Pain
Running an Effective Code Review
Tips for Doing Effective Code Reviews
How to Conduct Effective Code Reviews

Labels

adsense (5) Algorithm (69) Algorithm Series (35) Android (7) ANT (6) bat (8) Big Data (7) Blogger (14) Bugs (6) Cache (5) Chrome (19) Code Example (29) Code Quality (7) Coding Skills (5) Database (7) Debug (16) Design (5) Dev Tips (63) Eclipse (32) Git (5) Google (33) Guava (7) How to (9) Http Client (8) IDE (7) Interview (88) J2EE (13) J2SE (49) Java (186) JavaScript (27) JSON (7) Learning code (9) Lesson Learned (6) Linux (26) Lucene-Solr (112) Mac (10) Maven (8) Network (9) Nutch2 (18) Performance (9) PowerShell (11) Problem Solving (11) Programmer Skills (6) regex (5) Scala (6) Security (9) Soft Skills (38) Spring (22) System Design (11) Testing (7) Text Mining (14) Tips (17) Tools (24) Troubleshooting (29) UIMA (9) Web Development (19) Windows (21) xml (5)