Why code review is so important?

Why code review is so important?

It’s not in human nature to be able to check your own work unbiased. Editors are catching mistakes for authors and similar help is needed when it comes to authors of software – developers. That’s why code review is so important.

“If debugging is the process of removing software bugs, then programming must be the process of putting them in.” – Edsger Dijkstra (Dutch computer scientist, winner of the 1972 Turing Award)

Although purpose for code reviews varies a lot depending on environment, there are 3 main goals that every code reviews share:

  • Teaching and knowledge sharing
  • Ensuring coding standards
  • Defect-free software

Other very common goals are security, scalability, maintainability and complete unit tests.

How does it work?

“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” – Brian W. Kernighan (Canadian computer scientist, co-author of “C programming language”)

That’s why code reviews are so important.

Code review is the examination of code performed by developer (or developers) who didn’t write it in order to provide feedback. Feedback could be both negative and positive.

Reviewers are often working outside the project to maximize objectivity, but also to ensure that code written is readable and clear to everyone, not only for those deeply involved in the project. Typically reviewers are following checklists to find common mistakes and validate the code so that it can meet company’s coding standards.

Except for demos or experiments, it is crucial that code reviews take place during all stages of development. It is very important to perform such reviews even in final stages (when everyone is more focused on meeting deadlines), this is company’s and developer’s insurance for keeping company’s coding standards and can greatly reduce number of bugs. This means successful launch and less money spent on QA.

Code reviews help save your money

Finding bugs during development will be cheaper than finding them in QA, the sooner bug is found, the cheaper it is to fix it.

It is very hard for developer to find his own mistake, especially when a lot of features are added to the app (not always good a idea) but it can be detected more easily by someone else (fresh look effect). That’s why reviewers are looking for common mistakes and also focusing on finding those that are typically harder to find such as:

  • thread synchronization
  • error conditions
  • accounting for reference-counting
  • resource leaks
  • security problems

Maintainability

Software is not easy to maintain and it generates costs. It is especially true when one developer finishes the project and another one becomes responsible. It can also be difficult for a developer to know his way around the code he wrote 9 months ago.

Developing software doesn’t end simply with launching, it’s constant process so it’s best to ensure that code is clear for everyone and it can be modified when needed.

Code reviews help keeping code organized and adding adequate comments which can be priceless in the future – a person uninvolved, new to the project, will be able to read portion of code and understand it.

code-review

Learning and sharing

Every project is different and there are some unwritten rules. Tacit knowledge must be offered to people that are new arrivals to the project. It is impossible (or nearly impossible) to write this down, this kind of knowledge is usually acquired by making mistakes. Code reviews are the way of transferring knowledge between experienced developers and rookies.

Conclusion

Code review helps to launch successful product and save money. It is also great way to transfer knowledge. Senior developers can offer advice and their wisdom to juniors, and juniors help them by finding mistakes that seniors couldn’t see on their own, because they were so deep in the project. Code reviewing should be part of every stage of development.

Comments (1)

Jayan

Dec 31, 2016 at 8:51 PM

You’ve captured this peeycrtlf. Thanks for taking the time!

Reply

Leave a comment