Code Reviews: Easing the pain
sandr0-p
Posted on November 11, 2024
Most developers have met them throughout their career: Code Reviews. They are a crucial tool in software development and can help to ensure quality, consistency and maintainability. Yet, for many developers, the thought of a code review can bring a sense of dread. Why is that?
While there is a plethora of reasons for code reviews being viewed so negatively, I want to focus on consistency and predictability. What do I mean by that?
A code review should have roughly the same outcome, independent of who performs the review and the person's mood.
In this article, I will attempt to show a path towards a more positive and efficient experience for everyone involved, turning code reviews into an opportunity for learning rather than just a necessary hurdle.
The first step towards better code reviews is a shared understanding of their purpose and what a code review should entail. Without this shared understanding, every developer will focus on what they find important; thus, every code review will look different. The agreement should be as detailed as possible, preferably with examples or methodologies. It should be written down and made available in a central place.
Here are some of the things that I think are worth looking at:
- S.O.L.I.D Principles - Does the code adhere to the solid principles widely known to produce reusable code?
- Clean Code Development - Does the code follow the principles of clean code development?
- Pureness - Does the code use pure functions?
- Documentation - Is the code documented? In code and the technical documentation (where applicable)?
The eager reader will have noticed that the S.O.L.I.D Principles are already included in Clean Code Development. I listed them separately as I find they build a solid foundation for programming in general. (Pun intended)
Every seasoned developer and reviewer will find that list a little short. I agree. It is short on purpose. Many other tasks performed in a code review can and should be automated away. Executing tests? Done in the CI/CD pipeline. Naming conventions? Done using linting.
Most modern IDEs support plugins, allowing you to extend the IDE functionality based on your team's needs. You should use this capability to perform as many validations during development as possible. Many of these tools can additionally be used in CI/CD pipelines. In this way, code quality can be validated without a review, and the reviewer can focus on the aspects that actually require intelligence. It also makes a code review predictable. A reviewer shouldn't find anything if neither the IDE nor the pipeline reports any violations.
Last but not least, peer reviews. I know even more time is spent on code reviews. But, if done correctly, these sessions allow developers to learn from each other, provided they are interested. Over time the teams code will become more and more similar, making it even easier to perform a review.
Code reviews may never be a developer’s favourite part of the job. Still, by building consistency, using automated tools wisely, and fostering a culture of constructive feedback, we can transform code reviews into a positive experience. When reviews are predictable and focused on the most impactful elements, they become less of a chore and more of a valuable learning opportunity. By investing time in peer reviews, teams can align their code styles and principles, making future reviews more seamless and efficient. With the right approach, code reviews can strengthen code quality and team cohesion—turning an often-dreaded task into a cornerstone of continuous improvement.
Posted on November 11, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
October 11, 2024