DEV Community

How To Start Reviewing Code

Shubheksha Jalan on March 16, 2019

One of my goals at work has been to review code along with writing code. I have been trying to review more and more code and though it's fun, it ...
Collapse
 
kingnathanal profile image
William Britton

Code reviews are definitely a good way to learn because you can be exposed to different coding styles and designs. What helps me is having the team be consistent in what they are reviewing that way if you make a comment about something (ex. coding style: tabs or spaces) that is not normally not reviewed the author is not thrown off or offended. Excellent post.

Collapse
 
isabelcmdcosta profile image
Isabel Costa

Great post Shubheksha! I'm currently experiencing this at work. I'm reviewing code from merge requests where I know very little context about the project and I get to learn a lot with this (e.g.: about the technologies being used or getting a grasp of some projects within the company I don't get to touch very often).

Collapse
 
thomasjunkos profile image
Thomas Junkツ • Edited

Thanks for the great article!

One thing made me think:

Asking for more context is okay.

Yes, of course. It should always be okay, to ask for context.
OTOH if someone reviews my piece of code and asks me for clarification or context, I take it as a sign to improve my code.

Usually I strive to make my code as understandable as possible - although there are times, when I have to redo passages. But I find it very important that my code is understandable relatively independend of skill level and context.

At times, I wrote code which I had reviewed immediately by newcomers on the team. And when they did not understand right away what was going on, I redid the passage until they understood. The downside: that takes time, which one -unfortunately - does not always have. But I wish I could do it more often.

Collapse
 
yordadev profile image
yordadev

Code reviews are extremely important. I do them on myself few times a week before my commits get to far ahead of my last review.

Great post!

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

Avoid statements in code reviews, such as "Avoid statements". That is an option. Maybe use "could this be X" and most importantly, ask questions. Be the beacon on code quality and make yourself essential.

Collapse
 
andrewharpin profile image
Andrew Harpin

One addition I would make is that if you are going to provide a correction, justify why and demonstrate the benefits of your solution.