What is a code review, you ask? Well, let me tell you! But first, let me give you a little bit of insight into who I am so that you can understand why I find code reviews invaluable.

Background

At the beginning of September, I began my very first (sort of) work term as a co-op software developer here at Hootsuite. I say, “sort of” because I actually have a Bachelor of Science in Chemistry and have work experience in that field. As you can imagine, synthesizing chemicals and developing software are worlds apart, so my prior experiences did not directly help me become a better programmer.

image02
A typical day in the life of a chemist.

Once I began studying computer science and writing code, I quickly realized that my knowledge of best practices and code styles was very lacking. There are only a couple of Software Engineering courses at school that taught me elements of software development practices, but, even then, these were not the focus of the courses. The code that I wrote for assignments, projects, and hackathons was really only critiqued by me. Occasionally, a TA would comment on coding style, but for the most part, our assignments were automatically graded by scripts that just ran a set of inputs and looked for a specific output. Don’t get me wrong, I definitely tried to incorporate any tips and tricks that my professors talked about during lectures, but this only got me so far. I still found that I would occasionally write code that only I could comprehend due to its unnecessary complexity or code was full of technical debt (or “code smells”, for you UBC CPSC 310 students out there). This, of course, is where code reviews come in.

Every Writer Needs an Editor

So, what is a code review? It is literally what it sounds like. You write some code, and before you can merge it with the rest of the code in production, someone else has to review it and give it a thumbs-up. This, of course, also goes the other way: someone else writes some code and you get to review it, and if you think that their code meets the required coding standards then you give it a thumbs-up. Code reviews might sound like an obvious thing to do, especially if the code being merged immediately goes to production like it does at Hootsuite, but some people might think that code reviews are tedious and time consuming, especially for more experienced programmers.

On the surface, code reviews may sound simple and superfluous, but they are actually complex and provide a lot of value. Code reviews provide an excellent opportunity to maintain coding standards across a wide project, which allows for a more consistent codebase and is conducive to maintainability. They are also a great opportunity to deal with things that are difficult to automate, such as ensuring the correct text is wrapped in translation tags and escaping strings to prevent XSS attacks. Developers are able to ask each other questions and to critically analyze each other’s code, making changes as necessary. A code review also acts as a sanity check: are you duplicating code that may exist elsewhere? Are you doing something in an overly complicated way? Have you written tests for your code? The list goes on! Here at Hootsuite, we have a checklist included with every code review so that everyone can adhere to the same coding standards.

image00

Hootsuite didn’t always have code reviews or use branching: every developer was pushing code directly to master, and code reviews were only done voluntarily because there was no formal mechanism in place to enforce them. This was a conscious decision to allow for quick development and constant integration. Like other young start-ups, having the ability to move fast was integral to Hootsuite’s success at the time. However, because of the speed of development, the code base grew rapidly and became extremely dynamic, which made maintainability more difficult. Code reviews and branching were eventually introduced to improve the quality, reliability, and stability of our codebases.

For someone like me, code reviews are vital to my continuous learning. I’ve written code here at Hootsuite that I knew was full of technical debt, but I didn’t know how to improve it. I knew that getting that code review would be painful, but I looked forward to it because it meant that I could have someone help me improve my code and even my communication and problem solving skills. I am always asked to explain my code succinctly and to justify my decisions. Since I am able to code review anyone, and anyone can give me a code review, I am exposed to many ways of thinking and able to learn other people’s coding styles and evaluate my own.

Pay it Forward

I can imagine that, for experienced and senior programmers, code reviews provide value in many ways. Nobody is infallible, and having a quick sanity check to help catch mistakes is never a bad thing. Everybody approaches a problem differently, and code reviews are a chance for even senior developers to get someone else’s insight or potentially learn a new trick. As the reviewer, senior developers are able to impart their knowledge on whomever they give reviews to without it being a big time investment. This also enables the reviewee to absorb that knowledge and pass it on to others in the company.

Summary

While code reviews don’t catch all the bugs and mistakes, they do drastically reduce them. I can honestly say that having code reviews in place here has accelerated my learning and has helped make me a better programmer. Code reviews provide value to everyone and they are an awesome opportunity to pay it forward!

About the Authorimage01

Hai is a Co-op Software Developer on the Buzz (Customer Happiness) team at Hootsuite. He is passionate about travelling, film, and food. Find him on Instagram @jekyllwulf.