Code reviews, nitpicking and code convergence

By 2016-01-16 Programming No Comments

Code reviews are great

At work, we have pretty strict rules concerning code control. Each Pull Request needs to pass code reviews and needs two upvotes from fellow programmers before it has a chance to be merged. Since joining this spectacle i gained some, probably not all too new, insights.

Code style and individuality

In the Python world, it’s pretty safe to say that, when you are doing it right, there is only a certain range for how your code might look. That range is the famous PEP8. Usually you would try to not push any code to review unless it passes flake8 to not offend any coworkers 😉 That being said, after reviewing lots of code from coworkers, you find patterns and habits that would let you associate code with faces even if PR’s were sent anonymously and perfectly passed flake8. For example I am a huge fan of parentheses, no matter the interpreter version, like so

if (it is like_that): print("...and that's the way it is!")

instead of

if it is like_that: print "...and that's the way it is!"

There are lots of possibilities to give your code some unique character.  And while character is good for things like beer, cheese and footballers, a consistent codebase is best when free of any of these distractions!

Nitpicking and convergence

So what triggered me to actually write about this topic was an experience I made during the last 3-4 months at work while doing code reviews.

  • In the beginning I was clearly reviewing someone else’s code.
  • In the end I was reviewing my own code, just written by someone else! (except for the parentheses). While reading through the diffs, I would constantly think how familiar this code looks and feels. From variable naming, to codeblock patterns and commenting habits. Understanding of the code was immediate. It was a joy to review!
  • How did this happen? The constant code reviews during the last months, that explicitly did not treat style violations as peccadillos, are to blame! Code reviews that would sometimes (mostly in the beginning) have a dozen style comments pop up on the PR immediately, often even before the reviewer followed any logic. If you happened to be more on the squeamish side, such orgies can easily feel a little bit like nitpicking or pedantism to you. And yes, there would be discussions, sometimes purely focused on style.

Was it worth the time and effort?

Absolutely!!! These reviews and discussions surely took their time, but ultimately caused the code to synchronize! If you are serious about it, and meticulously report even tiny annoyances in the beginning, you will pretty soon only be talking about the real important things (like logic, technology or the biggest transfer mistakes of Bavaria Munich during the last decade…).

Leave a Reply