DEV Community

Cover image for The traits of a good code review
Maddy
Maddy

Posted on

The traits of a good code review

I've recently started a new software engineering role, and I performed my first code review a few days ago. If you don't know what a code review is, it's an activity carried out by software engineers, and it consists of checking someone else's code and look out for any mistake. When performing this activity, there are some aspects that you might want to consider to ensure that the code review is conducted successfully for you and your team members. Here is a comprehensive list of questions that you might want to ask yourself when performing a code review:

  • Is the code efficient both in terms of runtime and memory? Is the code secure? Code efficiency is essential because we want the code to be highly performant and reliable. For example, you might want to look out for redundant code, ensure that errors and exceptions are handled consistently throughout the code.
  • Is the input validated correctly? Certain parameters can only accept specific inputs. For example, can we take negative values?
  • Is there any more straightforward solution to the problem? It is a great software engineering practice to keep the code as simple as possible. You can look for the presence of multiple if statements, over-complicated patterns, complex loops, etc. Take any chance to make the code understandable and straightforward.
  • Is the code readable and well-formatted? Is the style consistent? Code should be written so that whoever comes later can easily understand what is going on. Check if variables are named appropriately, get rid of unnecessary spaces and tabs. Have a look at the pull request, and ensure that the code is always left cleaner than before. See if you can use better programming concepts to improve the quality of the code. Even the slightest improvement can make a massive difference.

A code review is a collaborative task that is beneficial to you and your team. Try to make it as constructive and pragmatic as possible. Give feedback with the intent to encourage improvement and explain why specific changes can benefit the code.

I hope you've found this helpful!

Top comments (0)