code review
coding, software development

10 things to look for in Code Review

Code review helps us to create high-quality software that has better code quality and has fewer defects. In addition, it also helps us to find a better design solution for the software through knowledge transfer during the review process.

Let’s see some key things we should keep in mind when we do a code review.

Functional Requirements

  • The code should serve all the functional purposes mentioned in the requirement.
  • It should be configurable according to business needs. For example -Business wants to give 10 % discount today, if they want to change it to 15%, it should be doable by config change and not code change.

Code Quality

  • The Code should have meaningful variable and function names
  • Constant and magic numbers should be properly defined
  • Functions should small and pure and have a single responsibility.
  • The code should be structured properly. For Instance, it should follow SOLID and DRY principles.
  • Follow all other clean code practices.

Database changes

  • Verify that changes should not impact performance
  • Verify that proper primary keys, foreign keys, and Indexes are defined.
  • Database changes should not impact any other code flow. For example, if you are adding or removing columns make sure it does not impact existing code flow.

Design Review

  • Define proper classes and components.
  • Each component should have a well-defined role and responsibility.
  • The code should have high cohesion and low couplingCohesion means keeping parts of a code base that are related to each other in a single place. Low coupling, at the same time, is about separating unrelated parts of the code base as much as possible
  • Verify the dependency of components is in the right order and interacting in the right order. For example- Your business logic should not depend on the database layer.

Configuration Changes

  • Proper configuration is defined for all the environments
  • Make sure configurations are not hardcoded.

Test cases

  • All the unit test cases should pass
  • Add unit test cases, functional test cases, and integration test cases for the code added.(Know more about test cases here)
  • Add test cases for all the positive and negative scenarios.
  • Code Coverage of test cases should not decreases
  • Even if codebase does not have test cases it is always a good time to start writing test cases.

API Design

  • Make sure APIs are following all the restful design principles. For example -GET to retrieve data, POST to create an entity.
  • Similarly, make sure APIs are returning proper status code in response. For example – 200 for success,500 for failure, and 403 for Access denied.

Logging and Error Handling

  • Add a meaningful amount of logging to debug issues in production when needed.
  • Add logger with proper logging level like INFO, ERROR, DEBUG, etc.
  • Make sure all the exceptions are handled properly.
  • Raise Custom Exceptions like UerNotFound Exception instead of generic exception.(raise e)
  • Always catch the specific exception and handle it properly. For example – Do not catch BaseException in your code.

Code Refactoring

  • Always take oppurtunities to refactor code and make it betterAfter some time code base will be in much bettr shape with less tech debt.

Please let me know if you think we can refine this list of code review and make it better

Follow us on

List of Best Courses for java

List of Best Courses for python

One thought on “10 things to look for in Code Review

Leave a Reply

Your email address will not be published. Required fields are marked *