Logo
AndreaDSW
BETA

How to Review Code Like a Pro

Last Modified:

Best practices and tips for conducting effective code reviews that enhance code quality and team collaboration.

Code reviews are a collaborative process where developers examine each other’s code before it becomes part of the codebase's project. Think of it as having a trusted friend proofread your work; however, instead of grammar and clarity, you’re checking for bugs, security issues, and overall code standards. It is common to set up in the projects automated tools like linters to help identify simple errors and code formatting issues beforehand. This way, the development team has the same formatting, removing this task during the reviewing process.

Sometime ago, one of my colleagues once told me something that stuck: “Code review is a time to scrutinise.” But he quickly added an essential caveat—scrutiny should never mean criticism. That’s why code reviews aren’t about finding fault with people; they’re about improving code together while building a culture of learning and collaboration.

The Golden Code Review Rules

1 - Always Be Polite and Constructive

Focus on the code, not the person. Instead of saying, “You always write messy code,” try, “This function could be simplified for better readability.” Remember, there’s a human being on the other end of your comments who put effort and thought into their work.​

2 - Suggest Solutions, Not Just Problems

When you disagree with an approach, offer an alternative. Therefore, rather than just saying “This isn’t right,” explain why and provide a concrete suggestion: “Consider using a Set instead of a List to prevent duplicates.”​

3 - Acknowledge Good Work

Balance critique with encouragement. Highlight what was done well: “Great job implementing this caching mechanism! This will significantly improve performance.” Positive feedback motivates developers and reinforces best practices.​

4 - Keep Reviews Focused and Timely

Review fewer than 200-400 lines of code at a time. Since anything larger decreases your ability to catch defects. Start reviews promptly—the author is waiting for feedback to continue their work. ​

5 - Use Positive, Specific Language

Be specific and actionable in your feedback. Don’t say, “This approach is bad.” Instead, explain: “Adding comments here would improve maintainability, especially for developers unfamiliar with this module.”​

My Personal Front End Code Review Practical Checklist

​ 1 - TypeScript Documentation Standards

  • Add JSDoc comments for interfaces and variables
    Use /** Comments */ format above TypeScript interfaces to describe what each variable does. This helps your IDE provide helpful hints to other developers and makes your code self-documenting.​
  • Component filename at the top
    Add /** TiledList.tsx */ at the beginning of each component file. This simple practice helps developers quickly identify which file they’re reviewing, especially when looking at multiple tabs.​
  • Use ReactNode for children's props
    If your component accepts { children }, import and type it as ReactNode from React. This ensures type safety and prevents passing incompatible content to your component.​

2 - CSS and Styling (Stylable Specific)

  • Check for unused CSS variables in .st.css files
    Review all colour variables, sizes, and CSS class names to ensure they’re actually used. Unused code bloats your application and confuses future developers.
  • Prefer Stylable components over HTML elements
    Instead of using raw <ul> and <li>, use framework components like <List> and <ListItem>. These provide better scoping and prevent style clashes across your application.

3 - Accessibility: Making Your Code Usable for Everyone

Accessibility isn’t optional—it ensures everyone, including people using screen readers or keyboards, can use your application.​

  • Add aria-expanded for show/hide toggles
    When elements toggle visibility (like dropdown menus or accordions), add aria-expanded="true" or "false" remove the clickable element. This tells screen readers whether content is currently visible.​
  • Use aria-controls to link toggles with content
    The toggle button should have a pointer aria-controls="targetId" pointing to the element it controls. This creates a clear relationship for assistive technologies.
  • Manage aria-hidden correctly
    When items are hidden, set aria-hidden="true"; when shown, use aria-hidden="false". This prevents screen readers from announcing hidden content.​
  • Add aria-label descriptors generously
    Provide clear labels such as aria-label="Main navigation menu" on <List> and <ListItem> components. These labels guide users with visual impairments through your interface.

4- Security and Best Practices

  • Avoid hard-coded IDs in HTML
    Never use id="ddd" directly in components. Hard-coded IDs can conflict with other elements on the page, especially when components are reused multiple times.​
  • Always use dangerouslySetInnerHTML for WYSIWYG content
    When rendering rich text from editors, wrap it safely: jsx
HTML
<Body dangerouslySetInnerHTML={{__html: "<h1> Tittle</h1><p>Hello <strong>bold</strong></p>"}} />

However, always sanitise this HTML first using libraries like DOM Purify to prevent XSS attacks. The name isn’t joking; it’s genuinely dangerous without proper sanitisation.​

5- Changes in Package Dependencies

  • Review package.json changes carefully
    When dependencies are added or updated, verify they’re necessary and trustworthy and don’t introduce security vulnerabilities. In addition, check for unnecessary packages that could bloat your application.​

Why Code Reviews Matter in Real Life

Code reviews aren’t bureaucratic busywork—they’re essential quality gates that catch bugs before users encounter them. ​Furthermore, beyond bug detection, reviews spread knowledge across teams.

When you review someone else’s code, you learn new patterns and approaches. Similarly, when someone reviews yours, you discover better ways to solve problems. This collaborative learning builds stronger, more versatile teams.​

Most importantly, good code reviews foster psychological safety. When developers trust that reviews are constructive rather than confrontational, they’re more willing to take creative risks, ask questions, and grow their skills. The result? Better code, happier teams, and more maintainable applications that serve users reliably for years to come.​