The Traits Of A Good Code Review

The Traits Of A Good Code Review

·

2 min read

I've recently started a new software engineering role and performed my first code review a few days ago.

What is a code review?

A code review is an activity carried out by software engineers, consisting of checking someone else's code and looking out for any mistakes.

Once software engineers have finished coding (tests included), the next step is to submit their code for a code review.

When performing a code review, there are some aspects to consider to ensure that the code review is conducted successfully for you and your team members.

Memory and security

Is the code efficient both in terms of runtime and memory? Is the code secure? Code efficiency is essential because you want the code to be highly performant and reliable. For example, look for redundant code and ensure that errors and exceptions are handled consistently throughout the code.

Input

Is the input validated correctly? Certain parameters can only accept specific inputs. For example, can you accept negative values?

K.I.S.S. principle (Keep It Simple Stupid)

This software design principle states that designs, solutions, systems, and products work best if they’re kept simple. It means we should favor simplicity over complexity and avoid complexity as much as possible.[Baeldung]

Is there any more straightforward solution to the problem? Keeping the code as simple as possible is a great software engineering practice. Look for multiple if statements, over-complicated patterns, complex loops, etc. Take any chance to make the code understandable and straightforward.

To achieve KISS:

Readability

Is the code readable and well-formatted? The code should be written so whoever comes later can easily understand what is happening. Check if variables are named appropriately and eliminate unnecessary spaces and tabs.

Did the developer pick good names for everything? A good name is long enough to fully communicate what the item is or does, without being so long that it becomes hard to read.[What to look for in a code review]

Look at the pull request and ensure the code is always 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.

Conclusion

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

I hope you've found this helpful!

Did you find this article valuable?

Support Maddy by becoming a sponsor. Any amount is appreciated!