Recommended resources
The freely available resources this lesson will direct you to.
Introduction
In our last lesson, you learned the Strangler Fig pattern, a powerful strategy for incrementally replacing legacy systems. This is a critical skill for modernizing applications, but modernization isn't just about replacing old code; it's also about ensuring the new code we write is robust, scalable, and maintainable. This brings us to a foundational practice of high-performing engineering teams: the code review.
This lesson will elevate your understanding of code review from a simple bug-checking exercise to a strategic activity essential for senior-level contribution. For you, on your path to a Senior Developer and Digital Manager, mastering this skill is non-negotiable. It's a primary mechanism for mentorship, upholding quality, sharing knowledge, and safeguarding the long-term health of a codebase. We will focus on how to conduct a constructive code review by evaluating code for its correctness, design, and maintainability, ensuring you're not just identifying problems but also fostering a positive and collaborative team culture.
1. The Code Review Mindset: A Human-Centered Process
Before diving into the technical checklist of a review, we must establish the correct mindset. A common misconception is that the sole purpose of code review is to find defects. While that is an outcome, its true value lies in collaboration and continuous improvement.
Effective code review is a dialogue, not an interrogation. It is one of a team's most potent tools for sharing knowledge, aligning on architectural principles, and mentoring colleagues. As a future leader, how you communicate during a review directly impacts team psychology, trust, and the quality of the final product.
The following talk by Michael Lynch, "How to Do Code Reviews Like a Human," provides an excellent foundation for this empathetic approach.
How to Do Code Reviews Like a Human
This talk reframes code review as a learning and team-building activity. It provides actionable communication techniques that are essential for conducting a constructive review.
Please watch the following segments: The introduction, where the speaker argues that reviews are for more than just finding bugs. The core assumptions, which highlight that we are dealing with humans who have emotions and specific learning patterns. The "Never say you" technique, a powerful way to remove ego from the conversation and focus on the code. Framing feedback as requests, which fosters collaboration and respects the author's autonomy. Offering sincere praise, which is crucial for building trust and reinforcing good practices.
The core principle is to focus on the code, not the coder. Your goal is to work together to improve a shared asset. A simple change in phrasing can be the difference between a defensive reaction and a collaborative discussion.

2. A Hierarchy of Review Priorities
With a constructive mindset established, the next question is where to focus your limited time and attention. Not all feedback is equally valuable. A senior developer's review should prioritize architectural health over stylistic preference.
This pyramid illustrates a helpful mental model for prioritizing your feedback.

Let's break this down:
-
Low Priority (Automate This): The base of the pyramid—syntax, style, and formatting—should not consume human review time. These are objective rules that computers excel at enforcing. Your team should use tools like linters (e.g., Checkstyle for Java, ESLint for JavaScript/React) and code formatters (e.g., Prettier) that run automatically, ideally as a pre-commit hook or in your CI pipeline. This frees up cognitive energy for what truly matters.
-
Medium Priority (The Foundation of Quality): The middle tier—security and maintainability—is where human expertise becomes critical. Is user input being validated to prevent vulnerabilities? Is the code easy to read, test, and debug? These aspects directly impact the long-term cost of ownership of the code.
-
High Priority (The Senior-Level Perspective): The peak of the pyramid is where you provide the most value on your path to a senior role: code health and architecture. Does this change align with the system's long-term architectural vision? Does it introduce unnecessary complexity or coupling? Could a different design pattern lead to a more robust solution? This is about looking beyond the immediate change and considering its ripple effects across the entire system.
The following reading from the Stack Overflow blog provides more depth on this distinction between a "good" review and a "better," more architectural one.
How to Make Good Code Reviews Better
This section clearly articulates the difference between a standard review and a more impactful, senior-level review that considers the broader system context.
Please read the section titled Areas Covered by the Code Review. Pay close attention to how it distinguishes "good" reviews (correctness, following guides) from "better" reviews (context of the larger system, abstractions, maintainability).
3. A Systematic Process for Reviewing Code
A structured approach ensures a thorough and efficient review. Here is a systematic process, combining insights from several expert sources.
Step 1: Understand the "Why"
Before looking at a single line of code, understand the purpose of the change. A great pull request (PR) description is your best friend here.
Code Review Tips (How I Review Code as a Staff Software Engineer)
Cody Engel, a Staff Software Engineer, shares his personal workflow. His initial steps are crucial for setting the context of the review.
Watch the segment from the beginning of his process. Note his emphasis on reading the description first to understand the changes, and then reviewing the unit tests to understand the code's intended behavior.
If the PR description is unclear, ask the author for clarification before proceeding. You cannot effectively review code if you don't understand the problem it's trying to solve.
Step 2: The Detailed Review
Now you can dive into the code itself. Use the following checklist, derived from best practices, to guide your analysis. This checklist directly maps to our goal of focusing on correctness, design, and maintainability.
Mastering pull requests. How to prepare and review.
This article provides one of the most comprehensive checklists available for what to look for during a code review. It's your technical toolkit.
Read the Check-list section in its entirety. As you read, mentally categorize the items under our three main pillars: Correctness: Does the code solve the problem and behave as expected? (e.g., "Functionality," "Error handling") Design: Is the implementation well-structured and aligned with architectural principles? (e.g., "Code design," "Complexity," "SDK/API usage") Maintainability: Will this code be easy for others (and your future self) to understand, modify, and test? (e.g., "Documentation," "Unit tests," "Naming," "Code readability")
Step 3: Formulate and Categorize Your Feedback
Once you've identified areas for discussion, craft your comments using the human-centered principles from Part 1.
- Be Specific and Offer Solutions: Instead of saying "This is confusing," say "I had trouble following the logic in this function. Could we perhaps extract this block into a separate method named
calculateInterest()to make the intent clearer?" Better yet, provide a concrete code example as suggested in the "How to Do Code Reviews Like a Human" video. - Categorize Your Comments: Not all feedback requires action. Clearly signal the importance of your comments. A common convention is to use prefixes:
[Blocking]or[Request Change]: For critical issues that must be addressed before merging (e.g., a security flaw, a bug, a significant design flaw).[Non-blocking]or[Suggestion]: For suggestions that would improve the code but are not mandatory. The author can choose to address them now, in a follow-up PR, or acknowledge and move on.[Nitpick]: For minor, stylistic preferences that are not covered by automated tooling. Use these sparingly. Too many nitpicks can be distracting and create friction.
Step 4: Know When to Go Offline
If you find yourself in a long back-and-forth thread of comments, it's a signal to switch communication channels. A 5-minute conversation over a call or in person can resolve what might take an hour of typing and potential misunderstanding.
4. Practical Application: Conduct a Mock Code Review
It's time to put these principles into practice and create a "paper trail of competence." Below is a snippet of code from a hypothetical OrderService in a Spring Boot application. It contains several issues related to correctness, design, and maintainability.
Your task is to review this code. In a new document in your personal knowledge base, write at least four review comments as if you were posting them on a GitHub pull request.
The Code to Review:
@Service
public class OrderService {
@Autowired
private OrderRepository orderRepository;
@Autowired
private ProductRepository productRepository;
@Autowired
private EmailService emailService;
// Method to process a new order
public Order process(List<Long> productIds, Long customerId) {
Order newOrder = new Order();
newOrder.setCustomerId(customerId);
newOrder.setOrderDate(LocalDateTime.now());
double total = 0.0;
List<Product> productList = new ArrayList<>();
for (Long id : productIds) {
Product p = productRepository.findById(id).get(); // Assumes product always exists
if (p.getStock() > 0) {
total += p.getPrice();
p.setStock(p.getStock() - 1);
productRepository.save(p);
productList.add(p);
}
}
if (total > 500) { // Magic number for 'premium'
total = total * 0.9; // Apply 10% discount
}
newOrder.setTotalAmount(total);
newOrder.setProducts(productList);
newOrder.setStatus("PROCESSED");
Order savedOrder = orderRepository.save(newOrder);
// Send confirmation email
emailService.sendOrderConfirmation(savedOrder.getId(), "customer@example.com");
return savedOrder;
}
}
Your Task:
Write at least four distinct review comments for the code above. For each comment:
- Follow the constructive communication principles (e.g., ask questions, use "we," avoid "you").
- Categorize the comment (e.g.,
[Blocking],[Suggestion]). - For at least one comment, provide a concrete code example for your suggestion.
- Ensure your comments touch on at least two of the three pillars: correctness, design, and maintainability.
Think about issues like error handling, separation of concerns (SOLID principles), "magic numbers," and testability.
Conclusion
You have now learned that a constructive code review is a sophisticated blend of technical acumen and emotional intelligence. It is a cornerstone of a healthy engineering culture and a key responsibility of a senior developer. By mastering this practice, you directly contribute to the quality of your product and the growth of your team.
Key Takeaways:
- It's a Human Process: The goal is collaborative improvement, not finding fault. Your tone and phrasing matter immensely.
- Prioritize What Matters: Automate stylistic checks to focus human attention on high-impact areas like architecture, design, and maintainability.
- Be Systematic: Follow a process of understanding the context, using a comprehensive checklist, and formulating clear, actionable feedback.
- Aim for Progress, Not Perfection: Especially in complex or legacy systems, the goal is to make the code better, not necessarily perfect in one go.
In our next lesson, we will delve into another critical skill for maintaining code health: applying a systematic 'divide and conquer' protocol for debugging complex issues. This will equip you with a structured approach to troubleshoot the very problems that a good code review process aims to prevent.