DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Testing, Tools, and Frameworks
  4. One Way of Doing Code Reviews

One Way of Doing Code Reviews

When it comes to code reviews, there are several ways to go about it. One dev shares his thoughts on the process he tends to use.

Nibal Sawaya user avatar by
Nibal Sawaya
·
Oct. 16, 17 · Opinion
Like (11)
Save
Tweet
Share
6.61K Views

Join the DZone community and get the full member experience.

Join For Free

Introduction

When it comes to code reviews, it all depends on your company and your team's mode of work, or the process that moves an idea into a software product.

With this article, I am presenting one way of doing code reviews, it is basically the way I do it, and I believe lots of developers have done it this way as well. I will first pinpoint the basic steps and then go through them in more detail.

I am assuming here that code reviews are made against code that is submitted with tests, indifferent to the way of development (test first, test last, ...).

In summary, the steps are as follows:

  1. Check if tests exist.

  2. Make sure all tests pass.

  3. Validate that the tests meet the acceptance criteria.

  4. Validate that the tests are properly written.

  5. Check the code for improvement suggestions. (Cleaner code, better structure, performance bottlenecks, un-used parts, etc..).

  6. Provide feedback to your colleagues using available tools.

I will now go through each of them in more details.

Check If Tests Exist

This is the most basic step and I believe it should be a requirement to never move your code into a ready for review state unless you have tests. The simple reasoning behind that is that your colleague cannot make sure that your code does what it promises to do, and without this minimum guarantee there is no point in reviewing the code.

Make Sure All Tests Pass

Now you can run the tests and make sure that nothing fails. This prevents colleagues from submitting buggy code, buggy tests or code with regression issues.

In case you have a CI/CD pipeline, the pipeline should include tests and this pipeline (if properly set) should cover other types of tests. 

Validate That the Tests Meet the Acceptance Criteria

The third step is basically a simple rundown of the acceptance criteria and the available tests. Of course, this depends on the process (company, team), so if you use BDD tests it is much easier to check that all cases are covered. 

Of course, this step assumes that you read very carefully the acceptance criteria and you have at least an idea of what kind of scenarios to cover.

Communication is key in all phases of development, so you will find yourself asking questions to your team colleagues, the business people, the product owners/managers to make sure that what is written in the acceptance criteria is the same as what the tests are validating.

The unit tests are covered in a later step.

Validate That the Tests Are Properly Written

Imagine all the previous steps are fine but then you notice that the written tests do not validate anything, or that the setup is wrong, or that some validations are missing. Sometimes the code setup (mocks or DB data setup or others) is very cumbersome that you even need to debug to check that the test data is valid first before checking the assertions against them later on.

In this phase, you will find yourself digging deeper into the code and assessing it, not just the way the tests are setup but also a bit of the implementation. Which eventually leads you to toggle between this step and the last one.

Check the Code for Improvement Suggestions

While checking the tests (especially BDD tests) you will start going deeper into the code. You will take notes about improvements in implementation algorithms, code structure, clean code, un-used parts, possible performance bottlenecks, and improvements.

You will look into the unit tests and validate them against the acceptance criteria (as sometimes they share some logic).

Provide Feedback to Your Colleagues Using Available Tools

This is the final step of the suggested process, now that you have assessed everything and you are ready to provide feedback. A few things can happen in this phase:

  • You are happy with everything; you just approved it and move the task/sub-task to done.

  • You have some minor comments. Depending on the available tools you either have to discuss your suggestions directly with your colleagues or add some comments on your code collaboration board.

  • You are suggesting big changes. In this case, communication is key, you discuss your changes with your colleagues, make sure you are correct about your assumptions, and the change is in fact needed, and then you can go into implementation according to the agreed-upon process. This could be pair programming, you do the change, your colleague does the change; it all depends on the agreed process.

Conclusion

This is just one way of doing code reviews and it assumes a lot of givens. I have made this post to get feedback, discuss different perspectives, and maybe find improvements and try them.

code style unit test

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Introduction to Container Orchestration
  • DevOps for Developers: Continuous Integration, GitHub Actions, and Sonar Cloud
  • Solving the Kubernetes Security Puzzle
  • Stop Using Spring Profiles Per Environment

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: