This 3 minute email will save you from slow and annoying code reviews


Fun Friday stat:

4 out of 5 developers enjoy the code review process.

(ok, that may or may not be entirely true)

But if you feel like you are beating each other with the stick during every code review, today's email will help.

I will guide you through 10 principles for legendary code reviews.

Let’s dive in.

1. Divide and rule

Is it funny, but I could summarize code reviews to the following process:

  • 10 lines changed = 10 comments
  • 1000 lines changed = 0 comments, LGTM (looks good to me)

The code review process will be faster and of higher quality when a developer has to review a small set of changes.

Therefore, follow the ancient rule of Macedonian kings:

Divide et impera.

Divide and rule.

Keep your code review changes as small as possible.

2. Automate the boring parts

Since your time isn't unlimited, look for repetitive tasks that you can automate:

  • verify the code builds
  • run automated tests
  • run code quality and security checks

Let the machines do boring tasks.

So you can focus on fun ones.

3. Ensure consistency with the style guide

If you want to eliminate fights during the review over how to style braces in code, use the style guide.

A style guide is a document that defines naming conventions, coding standards, and team practices.

It's essential for maintaining consistency.

So that the code looks like it was written by one developer.

Instead of 30 different.

4. Never point fingers

Avoid using the word "you" to ensure feedback focuses on improving the code, not on the individual who wrote it.

By critiquing the code rather than the coder, you reduce the chance of making your teammate feel defensive or taking the feedback personally.

Instead of:

"You must rename this method!"

Use one of the 2 approaches:

  1. Passive voice: "Can this method be renamed to X?"
  2. Use we instead of you: "Can we rename this method to X?"

You want to give feedback, not commands.

5. Limit the scope of the review

When you get the scope of changes that you need to review, limit the scope only to new changes.

Even if you see that the sorrounding code is not optimal, the whole process will be faster if you only check new changes.

Leave old changes in the past.

And deal with them separately in the future.

6. Approve while trivial fixes are left

Do you know the surest way to prolong the review process by at least a day?

Nitpick.

Look for little things like:

  • A variable should be "isDatePicked" instead of "datePicked".
  • You have a typo in "ProvideSugestion" method.
  • The indentation is inconsistent between lines 42 and 50.

How to have shorter review process?

Do the opposite of above.

7. Review your own code

Before you open your next pull request, review the code yourself.

This will seem unnecessary at first.

But you'll likely find things to improve.

And make a job a lot easier for other reviewers.

While reviewing, you can also...

8. Comment on your own code

As you are reviewing your own code, leave a comments on lines where you want opinions.

Or highlight the lines of code that might be improved/changed.

But you weren't sure how to do it when writing the code.

Remember this.

You are in the same boat as your coworkers.

You are all rowing in the same direction.

Toward a more maintainable codebase.

9. Don't ignore code reviews

When you get an assignment to review a code review from your colleague, act on it as soon as possible.

Because your review could block someone's further work.

How to know you have waited too long?

If someone reaches you with: "Can you review this PR I've created X time ago?"

Effective code reviews is a team game.

In order to get, you need to give.

10. Offer a pat on the back

Most review comments seem negative, like the weather report during a hurricane.

Nothing but stormy forecasts.

But what if we flip the switch?

And start offering positive, sunshine comments:

  • "I like how you've changed the code here. It's much more readable now."
  • "Good job on writing tests for that messy class."

Like a ray of sunshine, it may bring a smile to someone’s face.

Enjoy your weekend.

Kristijan

Kristijan Kralj

Weekly newsletter packed with code-improving tips, tools, and strategies to become a better .NET developer.

Read more from Kristijan Kralj

Lately, I’ve been paying more attention to what’s happening in the AI space. Maybe because of all the hype that surrounds it. Maybe because of the anxiety of whether AI will take my software development job. That's why I’ve decided to spend some spare time during the Xmas holiday to explore the state of AI software development tools. This email combines: My 1+ years of experience using a paid version of GitHub Copilot. 5+ hours of YouTube videos I’ve consumed in the last 2 weeks. So, let’s...

Today's issue is brought to you by the C# 13 and .NET 9 – Modern Cross-Platform Development Fundamentals. Build confidence in creating professional and high-performance web applications using the latest technologies in C# 13 and .NET 9 by Mark Price. Find out more here: C# 13 and .NET 9 Yesterday, We had a company Xmas party. Before dinner at a restaurant, we went to the escape room event. If you are unfamiliar with escape rooms, they're interactive puzzle experiences where you and your...

2 weeks ago, .NET 9 was released. If you haven’t had time to read the official release docs, don’t worry. I spent 1 hour investigating what's new in .NET 9. So you don't have to. Here are the top 10 improvements for C#, ASP.NET Core, and EF Core. 1. LINQ Index LINQ has always been an extremely useful tool for .NET developers. However, with .NET 9, LINQ comes with 3 new methods. Let's begin with the LINQ Index. The Index method places every collection element against its position within that...