· 3 min read
How to Code Review
This article was auto-translated from Chinese. Some nuances may be lost in translation.
Introduction
As a front-end engineer, you are often the one submitting pull requests most frequently across the team. To make your PRs easier to test and more straightforward for reviewers to review, I’ve summarized a few best practices.
Pull Request Descriptions
- State the purpose of the pull request (e.g., fixing a layout bug, adding a new feature, styling a specific screen, etc.).
- Remember that anyone in the company can view the pull request, so ensure the description provides sufficient and complete context.
- Clearly state what kind of feedback you are looking for.
- Use prefixes to indicate the status of your pull request (e.g., [WIP], [RFC]).
- Add the team members who need to review the code (you can use GitHub’s Assignee or Reviewer features).
Giving Feedback
- If you disagree with an approach in the pull request, pause and think about why you disagree before leaving a comment.
- Ask questions instead of giving commands. “Why didn’t you go with this approach?” is better than “Don’t write it this way!” Ask for their thoughts or rationale first; there might be a valid reason behind their choice, opening the door for constructive discussion.
- Explain why you think the code needs changes (Doesn’t follow the style guide? Violates company naming conventions? Missing test cases?).
- Suggest better alternatives to improve the current code.
- Avoid aggressive or dismissive comments (e.g., “Writing it like this is stupid.”).
- Stay humble.
- Avoid dogmatic assertions (e.g., “Never write code like that!”).
- Misunderstandings can easily arise in written communication. When that happens, consider talking face-to-face (or hopping on a quick call).
- Use emojis to soften or clarify your tone, like “good job 👋 👍” or “Needs a quick fix 👻” (well, maybe that ghost feels a bit sarcastic?).
Responding to Feedback
- Thank the people who take the time to review your code.
- If anything is unclear, don’t hesitate to ask questions.
- If the feedback has been addressed in a specific commit, link to it in your reply.
- If the discussion becomes overly complex or reaches an impasse, try talking it through in person.
For Everyone
- Understand that everyone has different coding styles, and there are often multiple valid ways to solve a problem. Weigh trade-offs pragmatically during discussions, and clearly explain why you believe one approach might be better.
- Ask questions instead of issuing orders.
- Avoid deflecting responsibility or creating silos (e.g., “You wrote this, not my problem” or “That part is yours to deal with”).
- Strive to understand the author’s perspective and reasoning.
Conclusion
While there are many points listed above, I believe it all boils down to being considerate of others. Approaching it from the perspective of “What kind of pull request would I want to review?” can make a huge difference.
After all, if a bug slips through—especially due to negligence—and makes it to production, it ends up wasting the entire team’s time tracking it down and redeploying.
Related Posts
- When a Measure Becomes a Target: From the Window Tax to Pull Request Counts I once wrote a script to tally how many PRs I contributed in a quarter, how many reviews I left, and how many tickets I closed, hoping to use numbers to prove my output to my manager. My manager simply remarked that performance isn't just about output. Years later, I finally understood—when a measure becomes a target, it ceases to be a good measure. From the British window tax and the Hanoi rat bounty to evaluating developers by PR counts today, the underlying mechanism is exactly the same.
- Using Cloudflare Images for Image Storage and Transformation Putting an image on a webpage is the simplest task in frontend development. But doing it properly—including resizing, generating multiple formats, and withstanding heavy traffic—is actually an entire end-to-end solution. Eventually, I offloaded everything to Cloudflare Images, keeping only a single original image.
- Stop Using AWS Access Keys Access Keys are an easily overlooked security risk in AWS. By pairing OIDC with IAM Roles, GitHub Actions can securely operate AWS resources without storing any secrets.
- Database Primary Keys: AUTO_INCREMENT, UUID, and UUIDv7 Backend developers often face the choice of primary keys: should you use auto-increment or UUID? What about collisions? How does UUIDv7 compare to created_at + index in performance? Here are the design decisions and benchmark results from testing 20 million rows.