Why Code Reviews Should Be Your Favorite Activity
And Why You Should Be Better In Code Review
Tips for being a better code reviewer, creating better pull requests, and accelerating with pull request analytics…
The code review process is an essential key to maintaining and improving product quality. But it can also be a bottleneck, unnerving activity for your development team, and may reduce your development productivity. Therefore, you should care about the best practices of the code review process outlined in this article.
- Why Should You Care About Code Reviews? 🤔
- 5 Tips To Be A Better Pull Request Reviewer. 🤓
- 4 Tips To Create Better Pull Requests. 😎
- Pull Request Analytics with Oobeya. 📊
Why Should You Care About Code Reviews? 🤔
Most of the development teams already know the importance of the code review activity as practitioners. This section tells C-Levels, Product Managers, and Engineering Managers that investing in the code review processes rewards you with better products and better development teams.
Development teams can improve their product quality, development skills, and team collaboration with a better code review process.
1. Product Quality ✅
Each product team wants to deliver faster while staying reliable. At this point, the code review process can be considered as a gatekeeper for the codebase. Code reviews:
- Prevent potential bugs, accidental errors, and structural errors.
- Improve code quality.
- Reduce and limit technical debt in the codebase.
- Keep the code clear, readable, and maintainable.
2. Personal Growth 💯
Code reviews offer an excellent opportunity for personal growth. It drives you to learn for code reviews and learn from code reviews. Code reviews:
- Make you more curious about clean coding, SOLID, DRY principles, etc.
- Force you to get a deeper understanding of the code.
- Give you a great chance to learn from others.
3. Team Collaboration 🙌
Code reviews increase team collaboration and get everyone together on the same page. Code reviews also create a unique opportunity for remote team members to interact with each other. Code reviews:
- Increase knowledge sharing within the team.
- Enhance team interactions and improve collaboration.
5 Tips To Be A Better Pull Request Reviewer 🤓
A pull request (or merge request) is a method to perform a code review activity for your codebase. You can find five tips below to be a better code reviewer:
1. Focus on Pull Request.
- Focus on the pull request, and fully understand its context.
- Find relevant tasks and documentation about the change requested.
- Ask “why” on each line of the change.
2. Comment on Pull Request.
- Comment on the pull requests. Explain the problematic units.
- Ask why and suggest better methods if necessary.
- Also, be kind and give constructive feedback. It may boost your team’s morale.
3. Improve your programming skills.
Always improve your programming skills and keep your knowledge up-to-date about programming best practices, clean code principles, etc.
4. Automate everything.
- Automation is the first gatekeeper of code reviews. Automate what can be automated in the code review process.
- Enable automated build, unit and integration testing, static code analysis, etc.
- Focus on the code, not on style. Style checks can be automated.
5. Care about time.
Time is important… Don’t be a procrastinator. Don’t block others’ work.
4 Tips To Create Better Pull Requests 😎
Before submitting a pull request for review, check out the four tips below by yourself:
1. Keep it small.
- Reviewers usually don’t dive deep into code if the pull request size is so big.
- If they decide to battle with your changes, it will take too much time to review the pull request and block other developers.
2. Code faster.
- Break large features into small pieces and keep the coding time short for each pull request.
- Reduce cycle time, see the problems earlier.
3. Review faster.
- Don’t let your code changes stale.
- Prevent potential merge conflicts.
4. Be ready to be reviewed.
- Review yourself before submitting your pull request.
- Give it a clear and descriptive title and write a good description.
- Check the style of the code.
- Run your local tests.
Pull Request Analytics with OOBEYA ✅
The code review process is a black box for engineering management. You may be familiar with code review best practices, but you may still have difficulty in managing and controlling this process.
You can get visibility into the code review process by using pull request analytics tools. With the help of pull request analytics tools such as Oobeya, you can:
- Learn if you have an efficient code review process or not. Detect your bottlenecks.
- Receive Slack/Teams alerts about oversized, stale, lightning, and overdue pull requests.
Pull Request Metrics 📊
See below the metrics of pull request activities and how you can improve your engineering process by tracking them.
1. Work In Progress
WIP PRs show open pull requests, risk labels, and bottlenecks of the development process.
You can see the risky pull requests and take action to resolve them earlier. Alerts and reminders for open pull requests can help you improve your cycle time.
2. Coding Time (Time to open)
Coding time shows the time elapsed between the first commit and open time for pull requests.
Long coding time may block developers to see the problems earlier. Long coding time is a major risk for the high cycle time. Developers should break large features into small pieces and keep the coding time short for each pull request.
3. Code Review Cycle Time (Time to review)
Code review cycle time shows the time elapsed between the open time and merge time of a pull request.
You can see the stale pull requests in red below. If code review time took longer than the goal, the pull request is identified as stale. Long review time is a blocker for development teams.
4. Pull Request Size
Pull request size shows the total changed size (lines added, removed, and changed) of a pull request.
You can set a goal for PR size and send alerts to Slack/Teams channels if the size is bigger than the goal.