Reading is Fundamental
And yet, it can be really hard to build a culture around code review. Developers don’t value it because it’s hard work, it’s work to benefit another person, and it’s time that you’re not writing code.
Code review forces you to read a lot of code. As programmers, we value writing code a lot. But reading code is just as fundamental a skill that is often overlooked.
1. You can’t write All of the Code!
No matter how long you keep at it, you will never be able to write all of the code :) Reading code, via code reviews, increases your exposure to code. This is good. This is how you get that fabled “experience”.
2. You read more code than you write, so you might as well get good at it!
Code is read more often than it is written. Over the course of your career, you will read far more code than you will ever write. Learning the ability to navigate an unfamiliar codebase and situate yourself and be able to reason critically about that code is an evergreen skill.
3. You gain insight into what makes code maintainable
Programmers aspire to write code that is clear and maintainable. Unfortunately, the feedback loop for your own code can be very long. You may never touch that piece of code again. Or, it may be many months or years before you need to modify it again and that is when you finally see if the past decisions you made have panned out.
When you perform a code review, you can immediately see the feedback on all of these things!
- You are reading somebody else’s code, so you have the distance and perspective to evaluate if it’s clear or not. You will need more than a gut feeling to explain your reasoning to another human being. This makes you conscious of what makes code understandable and you can take that back to your own work.
- When you are looking at a diff for a pull request, you can see both what the old code looked like and what the new code looks like. You can see how much the person had to change to make it work. Did they have to shoehorn something in? Were they able to re-use existing code/concepts?
Reading code productively takes a lot of discipline and practice. It requires you to be introspective and empathetic. These are valuable skills to work on and will make you a better programmer and a better team member. That’s worth it!