top of page

How to review your code?



Code review happens when another developer goes through you or your team's code line-by-line and provides constructive, helpful feedback. Code review saves time and effort by ensuring code quality up-front, rather than waiting until issues are discovered in production. It’s an essential part of the day-to-day lives of many professional software developers and data scientists.


Benefits:

  • The chance to fix errors that may cause issues in the future;

  • Compliance with standards and code style in the team;

  • Improving the solution architecture and design;

  • Verifying the compliance of the code with the task;

  • Improving the overall code quality;

  • Coders’ professional development;

  • Forming consistency in making specific decisions in the team.


Steps involved to review your code:



1. Establish goals

Code reviews are more than just finding errors and bugs. You may be thinking about adding new features and how to implement them. You may be trying to ensure that the code meets certain style standards established by your organization. Whatever the goals are, it’s important that you make them clear at the very beginning of the process, and that everyone on the team understands and works towards them. If each team member has a different goal or viewpoint, it will be difficult to reach a consensus and make progress.


2. Do your first pass.

Try to get to the initial pass as soon as possible after you receive the request. You don’t have to go into depth just yet. Just do a quick overview and have your team write down their first impressions and thoughts.


3. Use a ticketing system.

Most software development platforms facilitate comments and discussion on different aspects of the code. Every proposed change to the code is a new ticket. As soon as any team member sees a change that needs to be made, they create a ticket for it. The ticket should describe what the change is, where it would go, and why it’s necessary. Then the others on your team can review the ticket and add their own comments. Not only will this system help you keep track of all proposed changes, but the discussion will lead to further improvement and refinement of the overall code.


4. Run tests.

You can try to spot tiny errors by looking at line after line of code, but it’s often easier to run the piece of code in question and see how it works. In doing so, it’s easier to find bugs in the context of how they affect your application. It can also provide insight into what features are missing or could be improved.


5. Test proposed changes.

Put the code into your testing environment and see how it functions with the proposed changes. Do the changes work? Has the software improved, or have the changes caused more problems? Do these changes work for the project’s overall budget? What still needs to be done? Create more tickets for discussion, based on the tests.


6. Do your in-depth pass.

Now it’s time to sift through the lines of code with a fine-toothed comb and find the bugs, the style issues, the misplaced parentheses, etc. Some people prefer to do this before testing the proposed changes from the first pass. They’ll wait until the end and then test all the changes at once. But testing the changes from your first pass can help inform your second pass. Plus, testing as you go can save you time and money, as opposed to saving all of your testing to the end.


7. Submit the evaluation.

Minor changes such as coding errors and typos can be fixed as you go along. But major changes should always be discussed with the code’s author first. Ask yourself, is the change you’re proposing really a problem, or just something that you would have done differently? Because in the end, it’s their code, not yours. Once you’ve submitted your evaluation of the code, talk to the author and find out why they did things a certain way. Then tell them your approach and see what they think. Hopefully, you’ll be able to see things from each other’s point of view and use those insights to make the code the best that it can be.




How to Run a Code Review

Running a code review — and making sure everything has been properly reviewed — can be a huge challenge.


1. Communicate Goals and Expectations

You should be clear on what the goals of the review are, as well as the expectations of reviewers. Giving your reviewers a checklist will ensure that the reviews are consistent. Programmers will evaluate each other’s code with the same criteria in mind.


2. Include Everyone in the Code Review Process

No matter how senior the programmer is, everyone needs to review and be reviewed. After all, everyone performs better when they know someone else will be looking at their work. When you’re running reviews, it’s best to include both another engineer and the software architect. They’ll spot different issues in the code, in relation to both the broader codebase and the overall design of the product.


3. Foster a Positive Culture

Fostering a positive culture around reviews is important, as they play a vital role in product quality. It doesn’t matter who introduced the error. What matters is the bug was caught before it went into the product. And that should be celebrated.


4. Automate to Save Time

There are some things that reviewers will need to check in manual reviews. But there are some things that can be checked automatically using the right tools. Static code analyzers, for instance, find potential issues in code by checking it against coding rules. Running static analyzers over the code minimizes the number of issues that reach the peer review phase. Using tools for lightweight reviews can help, too.



Tools to review your code?

Code review tools help development teams work together on code, and they ensure code quality and consistency. These tools can provide a clear structure for the reviews, integrating them into larger development workflows. They can also streamline communication between the parties involved, providing a record of the process and allowing participants to more easily track what needs to be done.




1. GitHub

On GitHub, code review tools are built into pull requests. You can request reviews, propose changes, keep track of versions, and protect branches to improve the quality of your code.


2. GitLab

GitLab allows reviewing code, discussing changes, sharing knowledge, and identifying defects in code among distributed teams through asynchronous review and commenting. GitLab can automate, track, and report code reviews.


3. Bitbucket

Atlassian’s Bitbucket Code Review is a code-first interface that allows users to review large diffs, find bugs, collaborate, and merge pull requests.


4. Azure DevOps

Microsoft’s Azure DevOps code reviews are built into its Azure Repos and support a pull request review workflow. They offer threaded discussions and continuous integration.


5. Crucible

Atlassian’s Crucible is a lightweight code review tool that features threaded discussions and integrations with Jira Software and Bitbucket.


6. Gerrit

Gerrit is an open-source tool for web-based code reviews, with Git-enabled SSH and HTTP servers. Built upon the Git VCS, Gerrit’s patch oriented review process supports the typical workflow of open-source projects.


7. Upsource

JetBrains Upsource offers post-commit code reviews, pull requests, and branch reviews, along with project analytics. Code insight features, such as static code analysis and code-aware navigation, allow you to automate significant portions of the code review process.


8. JetBrains Space

JetBrains Space code reviews allow you to establish a customizable and integrated code review process with or without formal rules. Collaborate on code more easily, create merge requests, and protect your main branch with custom quality gates.


9. Review Board

Review Board is an extensible tool that supports performing reviews on a variety of file types, including presentations, PDFs, and images, in addition to pure code review.


10. AWS Code Commit

AWS CodeCommit is a source control service that hosts private Git repositories and offers built-in support for pull requests. It is compatible with Git-based tools, making it easy to adopt without significant tooling or workflow adjustments.

.

11. Phabricator (deprecated)

Though Phabricator was among the code review software used in 2021, with 3% of Developer Ecosystem Survey respondents identifying it as the tool they used, it can no longer be adopted by new users. Phabricator has been deprecated as of June 1, 2021, and new instances cannot be created.


12. Gogs/Gitea

Gitea and Gogs are open-source projects that aim to provide self-hosted Git services that are lightweight and easy to set up. Serving primarily, though not exclusively, Go users, these projects support a standard pull-request workflow for code reviews.


13. Collaborator

SmartBear’s Collaborator is a peer code and document review tool that integrates with a wide variety of IDEs and hosting services. It boasts a customizable workflow, allowing it to fit seamlessly into your pre-existing work processes.


14. Helix Swarm

Helix Swarm is a web-based code review tool for the Helix Core VCS. It integrates with the complete Perforce suite of tools, providing teams who use Helix Core with a range of resources for working collaboratively.



The Tech Platform

0 comments

Comments


bottom of page