Mathieu Perreault | 33962538 | 2017-07-29 00:32:58 | [diff] [blame] | 1 | # Respectful Changes |
| 2 | ## A Guide for Code Authors |
| 3 | |
| 4 | _For the code reviewer counterpart, see |
| 5 | __[Respectful Code Reviews](cr_respect.md)__._ |
| 6 | |
| 7 | ## Set up for success |
| 8 | |
| 9 | #### Do the pre-work |
| 10 | |
| 11 | Help challenging code reviews go smoothly by reaching out to prospective |
| 12 | reviewers before writing any code. Describing the problem and your approach |
| 13 | ahead of time reduces surprise and provides an opportunity for early input. |
| 14 | Ensure the decisions resulting from these exchanges, as well as the reasoning |
| 15 | behind them, are accessible to others (e.g. via bug or design doc). |
| 16 | |
| 17 | #### Mind your reviewer |
| 18 | |
| 19 | Make choices that spare your reviewer time or cognitive load, such as preferring |
| 20 | a series of short changes to a massive one, or uploading separate patches to |
| 21 | isolate rebases during review. |
| 22 | |
| 23 | #### Satisfy preconditions |
| 24 | |
| 25 | Ensure your code is ready for review before you send it: it should compile, have |
| 26 | adequate testing that passes, and respect the style guide (using _git cl |
| 27 | format/lint_ is encouraged). Consider validating this by performing a |
| 28 | self-review. This is respectful of reviewer time and can sometimes save you a |
| 29 | review round trip. If you're looking for an early review that's fine too, but |
| 30 | please say so. |
| 31 | |
| 32 | #### Remember communication can be hard |
| 33 | |
| 34 | Differences in understanding or opinions are to be expected in the context of |
| 35 | code reviews. Always assume competence and goodwill. Don't hesitate to suggest a |
| 36 | quick meeting (face-to-face or via VC); sometimes it's much faster to resolve an |
| 37 | issue that way than email ping pong. |
| 38 | |
| 39 | ## Request the review |
| 40 | |
| 41 | #### Choose your reviewers |
| 42 | |
| 43 | Give thought to whether you want to serialize or parallelize your reviews. If |
| 44 | you're new to the codebase, it's a good idea to do a first round with a single |
| 45 | local reviewer to clear the basic issues. Try to limit the number of owners you |
| 46 | solicit (only one per section), but ensure you pick sufficiently specialized |
| 47 | ones. Finally, be mindful of time zones and their effect on the review cycle |
Evan Stade | ce7bcd1 | 2025-03-31 16:46:46 | [diff] [blame] | 48 | time. Picking the right reviewers comes with experience, but start |
| 49 | [here](cl_tips.md#choosing-the-right-reviewers). |
Mathieu Perreault | 33962538 | 2017-07-29 00:32:58 | [diff] [blame] | 50 | |
| 51 | #### Provide context |
| 52 | |
| 53 | Change descriptions are the first impression your change makes, both on |
Johann | 48fbca9 | 2021-07-16 18:29:41 | [diff] [blame] | 54 | reviewers and on code archeologists from the future. A [good description](contributing.md#Uploading-a-change-for-review) |
Mathieu Perreault | 33962538 | 2017-07-29 00:32:58 | [diff] [blame] | 55 | aims to do two things. First, it conveys at a glance the high level view. |
| 56 | Second, it provides references to all the relevant information for a deep dive: |
| 57 | design docs, bugs, testing instructions. The bug\# is a useful reference, but |
| 58 | isn't sufficient on its own. Summarize **what** and **why** in the description. |
| 59 | You can additionally provide guidance on how to do the review in the e-mailed |
| 60 | message. |
| 61 | |
| 62 | #### State your expectations |
| 63 | |
| 64 | When sending the review, be clear to your reviewer about your expectations. In |
| 65 | terms of the review, this means specifying the kind of reviewing (e.g., high |
| 66 | level) as well as who should review what using which level of scrutiny. In terms |
| 67 | of timing, this means stating your deadline or lack thereof. For tight |
| 68 | deadlines, be convinced your urgency is real (hint: should be rare), and |
| 69 | communicate its reason, as well as your intent to land required follow up |
| 70 | refactorings. |
| 71 | |
| 72 | ## During the review |
| 73 | |
| 74 | #### Expect responsiveness |
| 75 | |
| 76 | Getting your code reviewed is about getting unblocked. You should expect |
| 77 | reviewer input within 1 business day. This should however be modulated based on |
| 78 | the size, complexity, urgency / importance of your change, as well as on |
| 79 | time zone differences. Beyond that, double check the reviewer's code review tool |
| 80 | nickname (e.g. "_jdoe (OOO til 4 Apr)_"), their calendar and ping them on IM. If |
| 81 | that fails, look for another reviewer. |
| 82 | |
| 83 | #### Address all comments |
| 84 | |
| 85 | Be convinced your reviewers feel all comments have been addressed before you |
| 86 | commit. Questions are addressed by providing an answer. Suggestions can be |
| 87 | addressed in one of three ways: adopt it immediately ("Done."), defer it to a |
| 88 | subsequent change (TODO with a bug \#) or push back with additional |
| 89 | information. Whenever more information is required, make sure everyone agrees on |
| 90 | the problem before you discuss the solution and consider expanding the |
| 91 | documentation. |
| 92 | |
kalettuce | aebff76 | 2023-04-06 20:43:07 | [diff] [blame] | 93 | #### Wait for LGTM from all your reviewers |
| 94 | |
| 95 | As a general rule of thumb, if a reviewer has made a comment on your CL, even |
| 96 | though you may have addressed that comment in a new patchset, don't submit the |
| 97 | CL until you have their LGTM, unless the reviewer gave the OK to do so (e.g. |
| 98 | when the reviewer delegates the reviewing task to someone else). If you need to |
| 99 | land a CL urgently and one of your reviewers isn't available (e.g. OOO), submit |
kalettuce | dd7e8846 | 2023-04-06 23:02:55 | [diff] [blame] | 100 | your CL, and send your reviewer a note; in the note, be sure to include the |
| 101 | reason why you had to land the CL, and show that you've considered their |
| 102 | opinions & are ready to promptly act on their additional comments in a followup |
| 103 | CL. |
kalettuce | aebff76 | 2023-04-06 20:43:07 | [diff] [blame] | 104 | |
Mathieu Perreault | 33962538 | 2017-07-29 00:32:58 | [diff] [blame] | 105 | #### What to do if it's going wrong |
| 106 | |
| 107 | Code reviews should not make you feel bad. If you find yourself in that |
| 108 | situation, or you feel the review's at an impasse, don't attempt to work around |
| 109 | a reviewer but take a step back. A face to face meeting or a VC can sometimes |
| 110 | help unblock a review. If this doesn't sound like an option, or simply if you |
| 111 | feel you need to talk about it, reach out to someone you trust. |
| 112 | |
| 113 | ## After the review |
| 114 | |
| 115 | Code reviews are in large part about having others watch your back. Don't |
| 116 | hesitate to say "Thank you" once the review is completed. Additionally, if |
| 117 | you're new to code reviews, take a few moments to reflect on what went well or |
| 118 | didn't. |