Skip to content

Things i learned on code reviews

code-review-cover

Code review is a powerful process that plays a crucial role in ensuring the quality and maintainability of software projects.

We will explore the step-by-step journey of a code review and the importance of collaboration in this process. Starting from the moment of reflection before opening a pull request to the valuable knowledge sharing that takes place, we will uncover the key aspects of a successful code review.

Step 1: Preparing for Code Review:

Before opening a pull request, take a moment of reflection to review your changes. Ask yourself important questions such as whether the code is readable, if it will be easy to maintain, and if there are any potential regressions. By addressing these considerations upfront, you can proactively improve the quality of your work and ensure a smoother review process.

Step 2: Shifting Perspective:

When submitting a pull request, it’s essential to remember that the code is not solely yours but belongs to the team. Embrace the collective ownership mindset, which helps avoid falling into traps such as gravitating toward personal coding style or seeking perfection. Recognize that the goal is to deliver the best solution as a team and be open to alternative approaches that enhance comprehension and maintainability.

Step 3: Engaging in Discussion:

Opening a pull request initiates a discussion between you and the reviewers. Expect questions about why certain decisions were made. Embrace this dialogue as an opportunity for knowledge sharing. Code review acts not only as a feedback mechanism but also as a platform for learning new patterns, approaches, and techniques. Emphasize clear and polite communication, fostering an environment where constructive feedback can be provided and received.

Step 4: Addressing Feedback:

As feedback is received, carefully consider each comment and suggestion provided by the reviewers. Evaluate the merits of the feedback and make necessary adjustments to your code. Remember that code review is a collaborative process, and incorporating valuable feedback strengthens the overall quality of the project. Be receptive, open-minded, and responsive to suggestions, as it is an opportunity for growth and improvement.

Step 5: Polishing the Code:

After addressing feedback, refine your code to ensure it meets the project’s standards and aligns with the team’s objectives. Pay attention to code formatting, readability, and maintainability. Strive for clean, self-explanatory code that is easy for others to understand and maintain in the future. By investing time in this step, you save significant effort that would otherwise be spent on testing and debugging later on.

Step 6: Collaborative Approval:

The ultimate goal of a code review is to achieve the “Looks Good To Me” (LGTM) approval from other engineers. This approval signifies that the changes are well-vetted, align with project requirements, and are ready to be merged. However, it is crucial to remember that the approval process is not just about seeking validation but about ensuring the best possible outcome for the project as a whole.

Conclusion:

Code review is a collaborative and iterative process that elevates the quality of software development. By following this step-by-step guide, you can effectively navigate the code review journey. Embrace the opportunity for collaboration, knowledge sharing, and continuous improvement. Remember to approach code review with an open mind, be receptive to feedback, and work towards delivering the best solution as a team. Together, we can create robust and maintainable software that stands the test of time. #codereview #pullrequest #softwareengineering #teamwork