DEV Community

Cover image for Code Reviews for Beginners: How to Send and Review Code Like a Pro
Nico Bistolfi
Nico Bistolfi

Posted on • Originally published at nico.bistol.fi

Code Reviews for Beginners: How to Send and Review Code Like a Pro

Code reviews are an essential part of the software development process. Whether you're sending your first code review or reviewing someone else's work, knowing how to navigate these waters is key to becoming a stronger developer. Let’s break down both sides of the code review process, from submitting your code for review to providing valuable feedback as the reviewer.

Sending a Code Review: How to Do It Right

When you submit your code for review, it’s not just about getting a "thumbs up" from your team. It’s about showcasing your work in a way that’s easy to understand, clean, and ready to integrate. Here’s how to approach sending a code review:

1. Ensure Your Code Is Clean

Before you even think about submitting your code, make sure it’s polished. Run tests, lint your code, and ensure there are no obvious errors or oversights. A clean submission sets the tone for a productive review. "It runs on my laptop" is just not good enough :)

2. Explain Your Changes

When submitting your code for review, context is critical. Provide a concise yet detailed description of what the code does, why certain decisions were made, and any potential areas that may require extra attention. The more information you give upfront, the easier it is for the reviewer to understand your thought process.

3. Break It Into Small, Manageable Chunks

Submitting massive pull requests can be overwhelming for reviewers. Keep your changes small and focused. Large, multi-purpose pull requests are harder to review and can easily introduce bugs that are hard to spot. Think that a code review shouldn't include more than 100 lines of changes, and within that take into account the cognitive load of the code you're submitting.

Being a Code Reviewer: How to Give Constructive Feedback with a Growth Mindset

Growth Mindset = trust your teammates, think what you can lear from what they did and how you're review may allow your teammates to learn too. A thoughtful review not only improves the code but also helps foster a collaborative and learning-focused environment.

Reviewing someone else’s code is just as important as writing your own, very likely you're responsible for maintaining that code (and people deserve PTO wink wink).

1. Be Respectful and Constructive

Remember, you’re reviewing someone’s work, not criticizing them as a person. Be positive, specific, and suggest improvements in a way that encourages growth. Instead of saying, “This is wrong,” try “This approach might be problematic in cases where X happens. Have you considered Y?” - if possible, talk to the person directly and initiate the dialogue.

As you build trust with your teammates, you'll learn to calibrate your message to the person receving the feedback and ensuring they receive it in the best possible way.

2. Focus on the Big Picture First

When reviewing code, it’s easy to get lost in the nitty-gritty details (like variable names or indentation). But first, focus on the big picture: Does the code solve the problem? Is it efficient? Is it maintainable? Once the major aspects are addressed, you can move on to smaller stylistic issues.

3. Ask Questions Instead of Making Assumptions

Sometimes, you won’t fully understand the reason behind certain coding decisions. Instead of assuming it’s wrong, ask questions. “Can you explain why you chose this approach?” is far better than saying, “This doesn’t make sense.” This opens up a conversation where the author can explain their thinking, and you might even learn something new.

4. Be Specific with Your Feedback

Generic feedback like “Looks good” or “Needs work” isn’t helpful. Be as specific as possible so the developer knows exactly what you’re referring to and why. Provide code snippets or links to documentation when possible to support your points.

Final Thoughts: Code Reviews Are a Learning Opportunity

Whether you’re sending or reviewing code, remember that the code review process is a learning opportunity for everyone involved. As the code author, you get to learn from feedback and improve your work. As the reviewer, you get to understand someone else’s code and share your expertise.

By approaching code reviews with respect, clarity, and collaboration, you’ll not only improve the quality of the code but also contribute to a stronger, more effective development team. Happy reviewing!

Top comments (0)