Why are code review and tests are so important for your code?!

Gilad lev-ari
3 min readNov 19, 2018

This next post is actually a talk I gave a few weeks back and thought it is so important I should share it with others.

Code review

Is a process, which one developer is reviewing the code of another developer.

Code review, should have a predefined standard and every developer may review any other developer’s code.

The pros

  • Another set of eyes to review your code. Letting some else to check your code might find edge cases or bugs you missed (Though I’m sure you are a top level developer)
  • Open your mind to other ideas.
    As another set of eyes check your code, Not only bugs and edge cases can be found in your code. A different developer can come up with different ideas on how to implement your code. Some might even help you improve it.
  • Code standard.
    Reading each other’s code, would eventually make you write the same way and will create a unified code standard.
  • Others, will be familiar with the code.
    Reading each other’s code will make you familiar with the code. Meaning you can continue the work of another and will make it easier for you to switch tasks between each other when in need.
  • You get your five minutes to relax. Some one else is sitting at your desk looking at your code. Go for a walk grab a cup of coffee, just relax while he or she, finds what’s wrong with your code 😂

The Cons

It was very difficult for me to find any cons with doing code review. But I did find one which in my opinion is very minor, it takes time.

Tests

Is an automatic process, which checks the implementation of the code is

continuous over time

The Pros

  • It will make us write a more readable code. If we want our code to be testable, we need to write smaller functions. Functions which handle one task. A better solution is to write pure functions. All of the above will make our code more readable, cleaner and easier to understand.
  • It documents our code. When writing a test, we actually write what we expect our code should do and what we expect it to result. Reading the test’s deceleration, is just like reading a short documentation of our code.
  • Decreases the number of bugs.
    when a test passes, it means the code does what it is expected to. This means, that as we write more tests, our code cover increases and our chances to miss on bugs decreases.
  • Writing test will eventually save us time and make our product better. If we write a cleaner more readable code and we decrease the number of potential bugs. We eventually save us time fixing all those bugs and our product is a more stable one. Meaning a better product.

I’d like to add one last thing in a more personal note. It is much FUN to see all your tests pass.

The Cons

One again it was very difficult to find cons in writing tests, but nothing is perfect. Writing tests, means you write code and it comes with all the baggage with it. You need to maintain it and update it once in awhile. Plus it takes time.

To conclude the topic, I’d like to say, maybe nothing is perfect BUT code review and tests has so many pros over cons.

I hope you’ll take my advice and code review each other and test your code.

--

--

Gilad lev-ari

Full stack web engineer with over a decate of experience and true passion for front end development and JavaScript 💪