Bad software code can quickly get expensive, so it’s always important to get it checked out by a fresh pair of eyes. Furthermore, it’s important to conduct a code review before going live as bugs can badly damage your reputation.
Writing code is a difficult endeavor and reviewing can also be just as difficult. As a result, having a checklist before reviewing the code can work as a guide and make the whole process a little easier.
All projects must start with a plan as it helps to establish the scope, objectives, and the steps to achieve them. Your code review checklist will also need to be incorporated into this plan to ensure that you achieve your predefined goals.
What are the key benefits of conducting a code review?
Beyond avoiding the financial consequences and damaged reputations caused by bad code, reviewing and testing your code will ensure that it’s well documented and correct. This process will also ensure that the code is algorithmically and architecturally efficient.
Code reviews also help you make sure that coding best practices are followed. What’s more, it’s a great approach to quickly spot bugs and resolve them during the development stage. This whole process will also help you ascertain who is a good team player and who is not.
Finally, code reviews also help ensure that the process and tools are working (and I’m not just talking about bug trackers and the repository here). These tools can be very helpful but only if they’re used on a regular basis (and it can also help keep developers maintain self-discipline).
When reviewing the code, developers must ask themselves if it’s good enough to be integrated with the existing codebase. Coders also need to ask if the code that they’re reviewing can completely break and derail the build.
This will depend on a variety of factors like the purpose of the target codebase, product features, the potential influence of the existing codebase, and the existence and severity of errors in the code.
The code review checklist will essentially be a set of questions. Let’s take a look.
1. Is code formatted correctly?
Formatting plays an important role in coding, so you have to ask a bunch of questions like the following:
- Does the layout of curly braces look right?
- Was the code generated using tabs or spaces?
- Where exactly are the spaces and line breaks?
2. Can you manually spot runtime errors?
Just by looking at the code, are you able to easily identify any runtime errors? In this scenario, try to reproduce the exception.
3. Are you able to compile it?
Mistakes will always happen, so take advantage of the integrated development environment (IDE) to identify them. Errors usually occur when developers forget to test minor changes, so a code review can help to rapidly identify it and resolve it.
4. What is the impact of those changes on the whole system?
When you’re looking at the code with little to no context regarding the rest of the codebase, you can easily miss errors. So developers need to look at all the other components that might be impacted by changes.
Furthermore, programmers should also look for any security holes that might have emerged. This is also a good time to figure out if any of the APIs were violated.
For a real world example of iOS app code review, check out this article on Medium.
5. Is the code logic correct?
It’s important to check if the code is logically correct and if it’s actually solving a problem. This part is central to the whole code review process, so it should never be overlooked.
Some other questions that you can ask are as follows:
- Is the code readable?
- Is the documentation sufficient?
- Are there any code styling problems?
- Is it within the project’s scope?
- Does it work?
Some of the code review processes can be automated, but the best approach is to have both a manual and automated process to ensure that you cover all bases.
Check out our Code Review Checklist Infographic
How do you go about conducting code reviews? Do you have any steps that can be added to this list? Pleas share your thoughts and experience in the Comments section below.