DEV Community

Manoj Sharma
Manoj Sharma

Posted on

Be a Responsible Code Reviewer

When you work with different teams long enough, you start noticing something meaningful:
Good code reviews don’t just improve the code—they strengthen teams, culture, and the way we write applications. Think about it...

That's where we actually teach each other new tricks / ways, share our best practices, and make sure we're all building something awesome, maintainable and reliable.

Let’s take a clear look... what a helpful, responsible code review really looks like. I am going to dig into the everyday's habits we fall into — the good ones and the ones that slow us down — and let's figure out better ways to handle them.

Why Strong Engineering Teams 💪 Treat Code Reviews Seriously?

Code reviews aren’t only about catching typos. They protect the applications’s correctness, design, and future maintainers.

Let’s analyze few of the reasons...

1. Catching Hidden Logic or Edge-Case Bugs

Sometimes the code looks fine, until someone else reads it carefully.

public double withdraw(double balance, double amount) {
    return balance - amount; // Looks fine, but...
}
Enter fullscreen mode Exit fullscreen mode

A reviewer notices:

  • Allows balance to go negative
  • No validation
  • Silent failures

A thoughtful improvement:

public double withdraw(double balance, double amount) {
    if (amount <= 0) throw new IllegalArgumentException("Invalid withdrawal amount");
    if (amount > balance) throw new IllegalStateException("Insufficient funds");
    return balance - amount;
}
Enter fullscreen mode Exit fullscreen mode

So this one small review prevented a production nightmare 😰

2. Improving Design and Readability

Developers often optimize for “it just works”.
Reviewers can help guide towards "it works and it makes sense here, they help reshape it before it becomes a problem later."

orderService.processOrder(order);
Enter fullscreen mode Exit fullscreen mode

But inside this method, total chaos! 🤯

public void processOrder(Order order) {
    // 200 lines of logic...
    // validation, transformations, ext calls...
    // Hard to read, hard to test, and even harder to change later.
}
Enter fullscreen mode Exit fullscreen mode

even if it Works today, but becomes a headache for anyone reading it tomorrow.

A reviewer suggests breaking responsibilities:

validateOrder(order)
applyDiscount(order)
reserveStock(order)
notifyUser(order)

Reviews improve the design instincts — something no tool can automate.

3. Spotting Performance & Concurrency Pitfalls

Performance issues often hide in plain sight:

Map<String, User> map = new HashMap<>();
synchronized (map) {
    // heavy operations
}
Enter fullscreen mode Exit fullscreen mode

Reviewer says:

You’re locking the entire map. That means only one thread can use it at a time.
Use a ConcurrentHashMap so multiple threads can work without blocking each other unnecessarily.

Small insight, big impact...but stay polite 🙌

How CI Helps Developers Trust Their Code?

Modern CI should take care of the repetitive checks, freeing reviewers to focus on real logic and blunders.

CI Handles What Humans Need not to

  • Basic static analysis
  • Null Pointers
  • High Logical Complexity
  • Code coverage
  • Security scans

If your CI is configured well, Reviewers need not to comment:

“Indentation wrong.”
“Rename this variable.”
“Remove unused imports.”

Most importantly it will take care of highlighting Vulnerabilities or Security concerns found in your latest changes.

Building a Learning Culture Through Code Reviews

A team that genuinely invests in code reviews gets better over time — because reviews are opportunity to learn new patterns, better designs, and even by reading other people's review comments educate everyone that this is how mistakes can be avoided... not just approvals to merge.

1. Tech Review Sessions With the Team

A simple habit strong engineering teams use:

  • Pick a PR that has some interesting design decisions
  • Walk everyone through what was done and why?
  • Talk about other possible approaches and their trade-offs
  • Note down anything useful for future work

This changes code review process from a private chat to something the whole team can learn from.

2. Knowledge Sharing Example

Suppose a developer introduces following piece of code

List<Order> orders = repo.findAll();
return orders.stream()
             .filter(o -> o.getStatus() == Status.COMPLETED)
             .sorted(Comparator.comparing(Order::getDate))
             .toList();
Enter fullscreen mode Exit fullscreen mode

And reviewer suggests:

List<Order> orders = repo.findByStatusOrderByDateAsc(Status.COMPLETED);
Enter fullscreen mode Exit fullscreen mode

Simple discussion here:

  • teaches why filtering and sorting at the source is more efficient
  • helps teammates recognize performance issues hidden in “harmless” code Reviews become mini lessons wrapped inside real code.

3. Language Modernization Through Reviews

Developer writes:

Optional<User> user = findUser(name);
if (user.isPresent()) {
    Address address = user.get().getAddress();
    if (address != null) {
        return address.getCity();
    }
}
return "anywhere";
Enter fullscreen mode Exit fullscreen mode

Reviewer suggests:

return findUser(name)
        .map(User::getAddress)
        .map(Address::getCity)
        .orElse("anywhere");
Enter fullscreen mode Exit fullscreen mode

No lecture — just a small improvement that exposes them to modern Java style.
This is how teams grow naturally.

How to Be a Responsible Code Reviewer ⭐️

Short, powerful, and practical.
No philosophy — just actionable mindset...

1. Understand The Context Before The Code

Read First:

  • PR description
  • Linked JIRA ticket
  • Commit message

You can’t review well unless you understand why the change exists.

2. Ask Questions, Don’t Command

Bad:

“Use Streams here.”

Good:

“Any reason Streams weren’t used here? they might simplify this block.”

Questions create collaboration; Commands create tension.

3. Praise Good Code When You See It

We often only comment when something is wrong.
But acknowledging good work helps morale and encourages a positive environment.

try (var client = new HttpClient()) {
    return client.fetch(url);
}
Enter fullscreen mode Exit fullscreen mode

Good comment:

“Nice use of try-with-resources — clean and safe.”

4. When You Reject Something, Reject the Code — Not the Dev

synchronized (this) {
    timeConsumingOperation();
}
Enter fullscreen mode Exit fullscreen mode

A harsh comment:

“This is bad, Why would anyone write this?”

Responsible reviewer:

“This might block more threads than needed. Can we lock only the shared part?”

5. Be Fast. Be Respectful. Be Honest.

Common anti-patterns:

  • Reviews slipping because of competing priorities.
  • Reviewer approves without reading.
  • Comments that are too short to be actionable (“Fix this”, “Why?”)

Responsible reviewer mindset:

  • Review within a reasonable timeframe.
  • Give actionable comments.
  • Being honest while staying respectful

6. Review the Scope — Not the Galaxy

If a PR is about “Add Get Users API”, don’t comment on unrelated parts like variable names in other unrelated methods.

Focus on: Functional correctness || Edge cases || Complexity
Don’t expand scope unless it’s truly necessary.

7. Don’t Just Point Out Problems — Propose Alternatives

A bad review makes the author feel stuck.
A good review helps them move forward faster.

public boolean isValid(Status status) {
    return status == Status.ACTIVE || status == Status.PENDING;
}
Enter fullscreen mode Exit fullscreen mode

Reviewer:

“Hardcoded checks”

Responsible reviewer:

These rules will grow. Let the enum own its behavior instead of scattering logic.

public enum Status {
    ACTIVE(true),
    PENDING(true),
    SUSPENDED(false);

    private final boolean valid;
    Status(boolean valid) { this.valid = valid; }
    public boolean isValid() { return valid; }
}
Enter fullscreen mode Exit fullscreen mode

One identifies the issue, The other one provides the solution as well...and allows dev to express their thoughts at the same time.

Wrapping up

That'it...
Repeating myself, Good code review process don’t just create better applications, They create better teams.
I’d love to hear from you people - What parts of the code review process frustrated you, and what changes made things better for you and your team? Share your thoughts 💭.

Top comments (0)