All code for our applications should be reviewed before it is merged. Code reviews help us:
Code reviews work best when they spark discussion between the coder and the reviewer. Sometimes, going directly to a code review is the easiest way for another developer to understand how and why you’ve chosen to solve a problem in a particular way.
Some comments in code review are straightforward — for example, syntax and whitespace issues. But others are an opportunity to learn for both the coder and the reviewer. If you don’t understand a comment or disagree with a suggested change, a code review is a great place to discuss it.
A good code review is an opportunity to reach a consensus. When a consensus between the coder and the reviewer can not be reached, a senior developer will make the decision. A code review is not an opportunity to disparage your code or criticize your coding ability.
The coder should expect:
The reviewer should expect:
In the course of your work, you will need to prepare pull requests and ask for code reviews. Typically, you should make sure that the tests are passing for your pull requests before asking for code review. However, in some cases, you may be asked to open a draft pull request for code review even before it is ready for merge.
To ask for a code review, post a description of the changes in the GitHub issue you are working on and list all of the related PRs. Here is an example.
@asmecher here is the work that I’ve done on the onboarding exercises. Can you review this?
PRs:
- http://…
- http://…
- http://…
Use a comment in the issue instead of assigning each pull request to the reviewer using GitHub’s assigned interface. This way the reviewer will get a single notification with all of the pull requests in one place.
When you have updated your code in response to review comments, post again in the issue to let the reviewer know that you are ready for a second round of review.
Remember that your pull request and code review creates work for someone else. The following will help ensure it is as easy as possible to review your code.
main
branch.And don’t worry too much. There’s no perfect pull request! Over time we will learn to adapt to each other’s coding and reviewing habits.