How To Write A Better Code Using Peer Code Review

In this article, you will find out what is code review, what do you need it for and how to do it without wasting your time and resources.

Code review helps to reveal bugs and mistakes in the code early in the development process. It is not only making your code better but also prevents bug fixes in the future.

Case studies provided by McConnell have shown that reviewed code had only 0.82 errors per 100 lines of code while those without review contained 4.5 errors per 100.

This is a significant difference, don’t you think?

It can increase productivity by 14% and decrease errors and mistakes in delivered projects even by 90%.

For clients, it means better quality and cheaper code while for developers and software development companies it can increase credibility and build good practices of coding within development teams.

Sign up to our newsletter for more mobile, web & wearables
design, development 
and marketing insights.

 

What is a code review

what is code review

The idea of code review is simple – once the code is written, another person examines it looking for overlooked mistakes and potential flaws, checks for quality standards and consistencies with client’s agreements.

At a glance, code reviews are being done to:

  • look for flaws, mistakes, and bugs,
  • assure that all cases are fully implemented,
  • check if the code is written with latest quality standards.

Doing code review allows finding mistakes early in the development process, saving both time and money on bug finding and fixing.

It also helps developers to better understand the process and learn from it, so it’s beneficial both for clients and development team as well.

To sum it up – code review helps to find flaws and mistakes before the development process ends and the app is delivered to the client, assuring its best quality and reducing bug fixes in the future.

 

The importance of code review

As I have mentioned above, doing code review can:

  • Help to validate the design and implementation of features
  • Save time (fewer mistakes, fewer bugs to fix)
  • Reduce the development overall cost (cutting bug fixes)
  • Help to deliver better quality of work
  • Let developers learn from each other in the process

It is best to have code review implemented as a part of the development routine workflow, to bring in the most benefits.

Although at Whalla Labs we conduct code review in the form of peer code review, in this article I want to walk you through the external review as well, so you can get a bigger picture of what code review is and how to do it.

 

What Is A Peer Code Review? (And How We Make It At Whalla Labs)

Peer review is a process of reviewing the each other’s code by developers in one team. It is the easiest and the most powerful way to get the most out of the process.

While reviewing each other’s code, developers can track flaws and mistakes, learning at the same time.

Junior developers can learn good coding practices from their senior colleagues, pointing out small mistakes they have overlooked.

At Whalla Labs, we’ve implemented code review into every sprint to make sure that at every stage of the development process we are delivering the best code possible. The review is conducted in teams, so only developers involved in the process can review each other’s code.

 

Peer Review Best Practices

code review

Image source

To increase your productivity and efficacy of peer code review, it is worth to follow these good practices:

 

Review fewer lines of code (LOC) at a time

It is obvious that you would like to review your code as fast as possible. The problem is that by doing so, you will miss a hell of a lot of bugs anyway.

Aim for 200-400 LOC at a time to discover more flaws. Reviewing more than that at a time will only make your brain tired and you will start to skip bugs you would’ve found otherwise.

 

Do not work more than 60 minutes at once

It is tempting to finish your review all at once. But again – like in the example above – you will only get tired and start to overlooking even the obvious flaws.

Take your time and you will increase the quality of your code review.

 

Make checklists

We are all humans and it happens to make the same mistake many times, in different projects. Working together with fellow developers you will find out the common mistakes they make.

Create a checklist of those flaws and you will be able to review the code faster, eliminating all those common mistakes in the first place.

 

What is external code review?

External code review is based on hiring an independent developer to perform an audit of the code written by in-house developers.

The reason to do so is to evaluate the quality of developer’s work, suggest good practices and to give a constructive feedback for developers.

External reviewer looks for improvement opportunities, so the final result is about to present developers information about flaws and mistakes they make in general while coding and to propose better solutions.

While one is for the most part aware of his coding strengths and weaknesses, an external audit can help to revisit them and help to improve.

 

When is it best to perform external code review?

As I’ve described above, the external review is all about looking for improvement opportunities, so the best moment to do one is when you want to move your development team forward and give them a push to upgrade their skills.

Just remember that it is not about judging the team’s work, but about bringing good practices and new working standards from the external authority.

As peer code review can help in everyday work by reducing flaws and mistakes, an external code review can bring new quality into the workflow.

Sign up to our newsletter for more mobile, web & wearables
design, development 
and marketing insights.

 

Taking care of the quality of your code starts now

As you can see, the code review can make a real difference to the quality of your work.

Doing peer code review, in general, can bring in a lot of value, requiring only a small part of your (and your colleague’s) time.

Let’s quickly recap the pros of doing it:

  • You write a better code.
  • You learn something new from your mistakes (and from those made by others).
  • More people in your team get to know what the project is about.
  • You will have to deal with fewer bugs in the future.

At Whalla Labs, we’ve found this convincing enough to always include code review when estimating new projects.

 

Recommended reading:

 

We are always very committed to delivering the best code possible. Want to learn more about how we do it? Download our portfolio or get in touch with us.