Code Reviews

One of my first tasks every morning is conducting code reviews, not only for members of my teams, but for members of other teams as well. I've made this one of my priorities for a year or so and they have taught me a lot. At my previous job, code reviews were never done.  Originally I was fine with this. I was scared of the feedback I might receive. I did not want people being critical of my code. However, I have come to realize that code reviews are great tools for learning and we can't let our egos stand in the way.

Before asking someone else to review my code, I always look at my code changes and give myself a code review. I ask myself a series of questions while doing my review and once I am satisfied it meets my requirements, I am then ready for someone else to review my code. Here are a few of my questions that I typically ask myself:

  • Would I approve of someone else making this change?
  • Did I do my best to make my code efficient and readable while still following our internal company guidelines?
  • Do my variable, method, and class names make sense?
  • Have I properly null checked variables?
  • Did I fully utilize Utilities and helper methods that are easily available?
  • Am I duplicating code?
  • Have I added useful comments?
  • Do I have any unused methods or variables? Have I commented out code that needs to be removed?
  • Finally, the most important question, but yet the hardest to answer sometimes, “Does this code actually fix the problem at hand, without introducing other bugs?

I also find code reviews to be helpful for reviewers as well. After a year of doing multiple code reviews a day, I now feel that I have a deeper understanding of our code base. It's also really helpful knowing what other features are being coded, because you never know when you might have to jump in and work with that same code. Doing code reviews can also be great for newer associates. It's a great place to begin to learn company coding practices and what is expected from engineers.

I sometimes encounter engineers who are reluctant to do code reviews. They might be shy or not feel as if they have the knowledge required to give a good code review. To these people I encourage you to start. The knowledge that you will gain will far outweigh any stress or anxiety they might bring. Even if you are not comfortable giving your own "ship it,” I'm sure there is something you and other engineers can learn.