PullNotifier Logo
Published on

Review code like a Senior Engineer

Authors

Why Code Reviews Matter

First of all - why do they matter? Well if a critical bug reaches production, it's not the coder's fault - it's the fault of the entire team.

Code reviews are a big deal. They (1) catch bugs early, (2) improve overall code quality (3) great for knowledge sharing (4) good for collaborating with your team (5) and so many more reasons.

Enough of that, you already know how important they are. You're here to learn about how to review code like a senior engineer.

Key Habits of Senior Programmers

Senior programmers have habits that set them apart. They know how to keep things running smoothly and maintain high standards.

First, they avoid unfinished work. They make sure to complete tasks before moving on, which keeps the codebase clean and organized.

  • Prevent Unfinished Work: Always finish tasks before starting new ones, keeping the codebase organized.

They enforce coding standards. This means everyone on the team writes code in a consistent style, which makes it easier to read and maintain.

  • Enforce Coding Standards: Consistent styling across the team for easier maintenance.

Documenting chosen patterns is another key habit. It helps everyone understand why certain approaches are taken, making future work easier.

  • Document Chosen Patterns: Clear documentation on why specific approaches are used.

Senior programmers review new patterns early. This means they catch issues before they become big problems.

  • Review New Patterns Early: Identify potential issues early on.

Meaningful naming is crucial. They choose names for variables and functions that clearly describe their purpose, making the code self-explanatory.

  • Meaningful Naming: Clear, descriptive names for variables and functions.

They don't hesitate to delete obsolete code. Keeping the codebase clean from unused code prevents clutter and confusion.

  • Delete Obsolete Code: Remove unused code to keep the codebase clean.

Participating actively in code reviews is a must. They provide constructive feedback and learn from others, which improves overall code quality.

  • Participate in Code Reviews: Engage in reviews to give and receive valuable feedback.

Senior programmers also write comprehensive tests. These tests ensure that the code works as expected and helps catch bugs early.

  • Write Comprehensive Tests: Ensure code reliability and catch bugs early.

They design with maintenance in mind. They think about how easy it will be to update and manage their code in the future.

  • Design for Maintenance: Plan for easy updates and management.

By following these habits, senior programmers keep projects on track and ensure high-quality outcomes.

Improving Team Comprehension

High-quality code enhances team comprehension. It makes it easier for everyone to understand what’s going on, reducing interruptions and confusion.

Forget the myth of 'self-documenting code'. While clean code is important, comments and documentation are crucial. They provide context that code alone can't.

  • Comments for Clarity: Good comments explain the 'why' behind the code. This helps others understand the reasoning without needing to ask.
  • Wiki Topics: Documenting broader concepts or common patterns in a wiki makes it easier for everyone to find and understand them.
  • Code Samples: Examples in the documentation can show how to use a function or module correctly, reducing errors.

Well-documented code is easier to maintain. It saves future developers time and effort because they don’t have to decipher what the original author intended. This means fewer interruptions to ask for explanations.

  • Maintainability: Clear documentation ensures that everyone can pick up where someone else left off. This keeps the project moving smoothly.
  • Reduced Explanations: When code is well-documented, there’s less need for lengthy explanations during reviews or onboarding.

By debunking the myth of 'self-documenting code' and emphasizing the importance of comments, wiki topics, and code samples, you make your codebase a friendly place for everyone. This reduces the friction of understanding and maintaining the code, which is a win for the entire team.

a cat sitting in front of a computer monitor

Conducting Thorough Code Reviews

Code reviews are more than just a check-off task. They build community, trust, and offer learning opportunities. When reviewing code, treat it as a chance to learn and teach.

First, understand the context. Ask questions like, "Why did they do it this way?" Make sure you grasp the purpose and logic behind the code before diving into specifics.

Avoid rubber-stamping. A quick glance and an approval won’t cut it. Take the time to go through the code thoroughly. Look for potential bugs, ensure coding standards are met, and verify that the code aligns with the project’s goals.

  • Understand Context: Ask questions to grasp the purpose and logic behind the code.
  • Avoid Rubber-Stamping: Take the time to review thoroughly, checking for potential bugs and adherence to standards.

Focus on the bigger picture as well as the details. Check if the code integrates well with existing modules and if it follows the project's architecture. This ensures that the code doesn't just work in isolation but fits seamlessly into the overall system.

  • Check Integration: Ensure new code fits well with existing modules and the project’s architecture.

Provide constructive feedback. Point out what’s good and what needs improvement. Use this as an opportunity to mentor less experienced developers. Constructive criticism helps everyone grow and improves overall code quality.

  • Constructive Feedback: Highlight strengths and areas for improvement, using it as a mentoring opportunity.

Learn from feedback. Code reviews are a two-way street. Be open to suggestions and improvements on your own code. This collaborative approach strengthens the team and the project.

  • Learn from Feedback: Be open to suggestions on your own code, fostering a collaborative environment.

By conducting thorough code reviews, you not only catch issues early but also contribute to a culture of continuous improvement. This habit is a key marker of a senior software engineer.

The Role of Testing in Code Reviews

Testing plays a crucial role in code reviews. It complements the review process by ensuring the code works as expected and remains reliable. When testing is prioritized, it significantly reduces the time spent on support and explanations.

Tests act as a form of documentation. They confirm the assumptions about the code, making it easier for others to understand the intended behavior. This is vital for maintaining high code quality and reducing the risk of bugs.

  • Reduces Time on Support: Well-tested code means fewer issues and less time spent fixing bugs.
  • Ensures Reliability: Tests confirm that code changes don’t introduce new problems, keeping the project stable.
  • Acts as Documentation: Tests provide a clear understanding of what the code is supposed to do.

Testing helps catch errors early. During a code review, tests can reveal issues that might not be obvious from just reading the code. This early detection saves time and effort in the long run.

  • Early Error Detection: Tests identify problems before they escalate, saving time in the development process.

Additionally, tests make the review process smoother. When reviewers see that comprehensive tests are in place, they can focus more on the logic and structure of the code rather than worrying about its functionality.

  • Streamlines Reviews: Comprehensive tests allow reviewers to focus on code quality and logic.

By integrating thorough testing into your workflow, you ensure that the codebase remains high-quality and maintainable. This practice is essential for senior software engineers who aim to deliver robust, reliable software.

Documentation and Code Comments

Documentation and code comments are key for keeping context and sharing knowledge. They help everyone understand why code decisions were made and make it easier to maintain and grow the codebase.

Good docs and comments keep the team on the same page, especially during code reviews. Here are some useful types of comments and documentation:

  • Explain the 'Why': Comments should tell why we chose a certain approach, not just what the code does. This helps others get our reasoning.
  • Point Out Workarounds: If there's a quick fix in the code, document it. This helps future devs know it's temporary and plan for a real fix.
  • Mark Complex Parts: For tricky code sections, add comments to guide others through the logic. This keeps code quality high and cuts down on confusion.

Besides inline comments, solid documentation is crucial. This includes:

  • API Docs: Clearly explain the inputs, outputs, and expected behavior of public functions and methods. This helps other devs use your code right.
  • Architecture Notes: Keep notes on big-picture design decisions. This helps new team members quickly grasp how systems work together.
  • Setup Guide: Document how to set up development environments. This helps new devs get started smoothly.

Good docs and comments provide context, making code easier to understand and maintain. They help share knowledge built up by devs, making sure important info isn't lost over time.

Focusing on documentation and comments leads to better code reviews and team alignment. This practice boosts code quality and fosters a collaborative, informed dev environment.

black samsung flat screen computer monitor

Reducing Technical Debt

Reducing technical debt is crucial for maintaining a healthy codebase. Here’s how you can keep things in check and ensure your code stands the test of time.

Start by adopting disciplined coding practices. Make sure to enforce coding standards across the team. Consistent code style and rules make the codebase easier to read and maintain.

  • Consistent Standards: Enforce a unified coding style to simplify maintenance.

Avoid exposing refactoring tasks separately. When you find an area that needs refactoring, tackle it as part of the current work rather than deferring it. This keeps the codebase modern and prevents the buildup of technical debt.

  • Integrated Refactoring: Address refactoring needs within the current task to keep the codebase clean.

Documentation is your friend. Maintain clear and thorough documentation for your code. This includes inline comments, architectural notes, and setup guides. Good documentation helps future developers understand your code and reduces the need for lengthy explanations.

  • Maintain Documentation: Keep detailed docs to help others understand your work.

Don’t be afraid to delete obsolete code. Unused code clutters the codebase and can lead to confusion. Regularly review and remove code that’s no longer needed.

  • Delete Obsolete Code: Clear out unused code to keep things tidy.

Perform thorough reviews. Take the time to go through each pull request in detail. Look for potential issues, ensure code quality, and verify that the code follows best practices. This not only catches bugs early but also ensures that the code adheres to project standards. For teams looking for tools to streamline this process, consider using PullNotifier to enhance your GitHub and Slack integration, making it easier to stay updated on pull requests and maintain high-quality code.

  • Thorough Reviews: Examine pull requests carefully to maintain high-quality code.

By following these strategies, you’ll reduce technical debt and ensure your code remains robust and maintainable. This approach helps your team work more efficiently and keeps the project on track.

Maximizing Tools as a Senior Engineer

Senior engineers know how to leverage tools to enhance team productivity and ensure smooth workflows. They don't just focus on writing clean code; they also optimize processes by setting up and using the right tools that can benefit the entire team. These tools help automate mundane tasks, improve code quality, and provide better visibility into the development process.

  • AI Code Reviewers: By integrating AI-powered code review tools, senior engineers can automate the detection of common issues, freeing up human reviewers to focus on more complex logic.
  • PullNotifier: Tools like PullNotifier streamline communication by keeping the team updated on pull requests in real-time, ensuring that code reviews happen promptly and that nothing falls through the cracks.
  • SonarCloud for Code Quality: Senior engineers often incorporate tools like SonarCloud to continuously monitor and maintain high code quality. This helps identify bugs, security vulnerabilities, and technical debt early in the process.

By setting up and utilizing these tools, senior engineers make it easier for the whole team to maintain high standards, collaborate effectively, and keep the project moving smoothly.

TLDR;

I know you're a busy x10 engineer. So here's a run down of all the points covered on this post:

  • Importance of Code Reviews: They catch bugs early, improve code quality, and promote knowledge sharing. Reviews boost collaboration and ensure adherence to best practices, keeping the project on track.
  • Habits of Senior Programmers: Senior programmers prevent unfinished work, enforce coding standards, document chosen patterns, review new patterns early, and use meaningful naming. They actively delete obsolete code, participate in code reviews, and write comprehensive tests. Their approach ensures the codebase remains clean and maintainable.
  • Improving Team Comprehension: High-quality code makes it easier for everyone to understand. Good comments and thorough documentation provide context that code alone can't, reducing interruptions and confusion. This keeps the project moving smoothly.
  • Conducting Thorough Reviews: Understand the context, avoid rubber-stamping (instant approvals), and check integration with existing modules. Provide constructive feedback and be open to learning from others. This fosters a collaborative environment and continuous improvement.
  • Role of Testing: Testing confirms assumptions, acts as documentation, and catches errors early. It streamlines reviews, ensuring the code is reliable and functional, which reduces the time spent on support and explanations.
  • Significance of Documentation: Good documentation and comments keep the team aligned, providing clarity on code decisions and making maintenance easier. This practice preserves important knowledge and helps future developers.
  • Reducing Technical Debt: Enforce consistent coding standards, integrate refactoring tasks, maintain thorough documentation, and regularly review and delete obsolete code. Thorough reviews and disciplined practices help keep the codebase robust and maintainable.

By implementing these practices, you’ll elevate your code reviews and contribute to a high-quality, maintainable codebase. These habits not only improve individual contributions but also enhance the overall team’s productivity and project success.