Software Code Review – Best Practices

Code Review – Best Practices
Abhilash Gopi
Cordiant Technologies

Code Review

• Code review is best applied in a Top-Down order
• Code to be incrementally documented.
• Code evolution – We will need to be on top of this.
Code Evolution?

• As the code evolves, it provides us a basis for learning and avoiding mistakes.

Why do we need Code reviews?

• Software engineering projects are classified in the Type 2 category of Projects, hence are
very risky and difficult to maintain.
• We always need to find methods to improve maintainability of the code, since the same
programmer may not be available the next time.

Why do we need Code reviews?

• Maintenance
• The code should be easily modifiable.
• We should be able to add new features and resolve issues easily
• Evolution
• In order to add a feature, we need to know where to add and how to add.
• Learning/ assimilation
• Once code is reviewed and updated, it provides a basis for others to follow similar terminology and coding approach.
• Hence code uniformity is maintained.

How it aids us?

• A new programmer who is asked to work upon a new feature or an existing issue in the
current code
• Should have a fair understanding of the code
• How can it be done? Let’s see.

Eagle method

• Always stay on top
• Dive into the detailed code only if required.
• E.g. Do not try to read 100K lines of code from the beginning to the end.
• Read in increasing level of detail
• Directory level
• Structure level
• Code level
• In short, maintain a bird’s eye view until it is required to zoom down to the details.

Guidelines -Directory level

• Size and Complexity
• Get a fair idea of the No. of packages, Files, Classes, Lines of Code
• Documentation
• Refer to the standard set of README, HELP files
• Build process
• Refer to the individual builds, Configurations,
Compilation involved, Linkage
• Unit tests
• Refer to the code and their corresponding Unit tests.

Guidelines – Structural level

• Refer to the Design patterns
• Refer to the Data Structures and their interfaces.
• Refer to the Framework
• Error Handling/ Logging/ Commandline parsing
• Math features
• GUI/ Graphics
• I/ O
• Wrappers/ Interfaces

Guidelines – Code level

• Refer to coding conventions
• Naming conventions
• Formatting rules, layout, indentation
• Commenting rules
• Control structures

Advantage of coding standards

• Coding standards are useful if used consistently across the project
• Even if it is outdated, continue making use of them within the same project to cater to the
uniformity and maintainability.

How to do code review?

• If you are hungry and want something, you need to let alone the bones and skin and get to
the meat

How to do code review?

• Skip
• Preprocessor statements
• Initialization
• Look for
• Text (window titles)
• Outputs/ printouts
• Comments
• Inner loops

Why code review should be immediate?

• It will not allow us to generate SPAGHETTI code
• Colleagues could get lost in trying to insert a new feature or resolve an existing issue
• Time “LOST” formatting code is regained only in the second cycle/ iteration of review.

Code Evolution – Advantage

• When adding new code it is time to apply the best practices learned during the code review.
• At the end, we generate good code.

Your Skill requirement

• Reading and reviewing a code
• Is a “soft skill” to be learned by experience
• Goes hand-in-hand with writing new code

Code Review

• Ensure that you have some basic code review.
• More important is having the best practices and deviations put across to your team, to
avoid repeated occurrences.
Thank you


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s