Best practices for code authors

Greg Foster
Greg Foster
Graphite software engineer

For code authors, the way you prepare and present your code can significantly influence the efficiency and effectiveness of the code review process. The following best practices, sourced from industry research and insights from teams at Microsoft, outline a strategic approach to making your code as review-friendly as possible.

Overview: Code that is easy to understand and evaluate is paramount for a smooth review process. This involves writing clear, concise, and self-explanatory code that adheres to project guidelines and best practices.

Practices to Follow:

  • Read Through Your Changes: Before submitting for review, meticulously go through your changes, ensuring they are free of obvious errors and are ready for others to view​​.

  • Aim for Small, Incremental Changes: Large changes can be overwhelming and difficult to review. Small, coherent changes are more digestible and likely to be understood and accepted quickly​​.

  • Cluster Related Changes: Organize your pull requests such that each one encompasses a single functional change. This aids reviewers in grasping the purpose of your changes and provides clearer feedback​​.

Overview: Feedback is a gift that comes with the potential to significantly improve code quality. The manner in which you respond to this feedback can affect both the code and the collaborative atmosphere.

Practices to Follow:

  • Be Open to Suggested Changes: It's natural to feel defensive about your work, but stay open to feedback and consider it with an open mind, assuming positive intent from reviewers​​.

  • Show Respect and Gratitude: Acknowledge the effort reviewers put into their feedback. Communicate the actions you took in response to their feedback and the decisions you made, maintaining a respectful tone throughout the interaction​​.

Overview: Refactoring is about enhancing the structure and quality of code without altering its functionality. It's an essential part of writing maintainable and scalable code.

Practices to Follow:

  • Provide Clear Descriptions: Help reviewers understand the context by providing detailed descriptions of the changes, especially if the modifications are not self-explanatory​​.

  • Run Tests Before Submitting: Ensure that all tests pass before submitting for review. This demonstrates respect for the reviewers' time and minimizes the churn in the review cycle​​.

  • Automate When Possible: Use tools for automated testing, style checking, and static analysis to catch issues early. This allows reviewers to focus on more substantive feedback rather than catching trivial errors​​.

These practices, grounded in research and validated by industry experience, provide a blueprint for code authors to facilitate productive and positive code reviews. By adhering to these principles, you contribute to a collaborative environment that values quality and continuous improvement.

Stay unblocked. Ship faster.
Experience the new developer workflow - create, review, and merge code continuously. Get started with one command.
Get started

Give your PR workflow
an upgrade today

Stack easier | Ship smaller | Review quicker

Or install our CLI.
Product Screenshot 1
Product Screenshot 2