Code Review Flashcards

1
Q

What should Nit: prefix be used for?

A

To let the author know that it’s just a point of polish that they could choose to ignore.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Senior principle for approving a PR?

A

Approve once it’s in a state where it definitely improves the code health, even if the PR isn’t perfect.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

3 principles of code review

A
  1. Technical facts > opinions and personal preferences.
  2. Any purely style point that is not in the style guide is a matter of personal preference.
  3. If several solutions are equally valid, then the reviewer should accept the preference of the author.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Conflict resolution escalation strategy

A
  1. Seek consensus in PR comments
  2. F2F meeting + conclusion notes in PR comments
  3. Escalate to the team, eng manager
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What to look for 1: Overall Design?

A
  1. Do the interactions of various pieces of code in the PR make sense?
  2. Does this change belong in the codebase or in a library?
  3. Does it integrate well with the rest of the system?
  4. Is this a good time to add this functionality?
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What to look for 2: Functionality?

A
  • Does this PR do what the developer intended?
  • Is what the developer intended good for the users of this code?
  • Think about edge cases, concurrency problems
  • Click through a demo for UI-related PRs
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What to look for 3: Complexity?

A

Is the PR more complex than it should be?
“Too complex” usually means “can’t be understood quickly by code readers.” or “developers are likely to introduce bugs when they try to call or modify this code.”
- Look for overengineering and encourage solving only relevant problems.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What to look for 4: Tests?

A
  • In general, tests should be added in the same PR as the production code.
  • Don’t accept complexity in tests just because they aren’t part of the main code.

Helper questions:

  • Will the tests actually fail when the code is broken?
  • If the code changes beneath them, will they start producing false positives?
  • Does each test make simple and useful assertions?
  • Are the tests separated appropriately between different test methods?
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What to look for 5: Naming?

A

Did the developer pick good names for everything?
A good name is long enough to fully communicate what the item is or does, without being so long that it becomes hard to read.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What to look for 6: Comments?

A

Are all of the comments actually necessary and grammarly correct?
Usually comments are useful when they explain why some code exists, and should not be explaining what some code is doing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What to look for 7: Documentation?

A

If a PR changes how users build, test, interact with, or release code, check README.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What to look for 8: Every line?

A
  • Look at every line of code that you have been assigned to review.
  • You should at least be sure that you understand what all the code is doing.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What to look for 9: Context?

A
  • It’s useful to think about the PR in the context of the system as a whole.
  • Don’t accept PRs that degrade the code health of the system.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What to look for 10: Good Things?

A

If you see something nice in the PR, tell the developer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How to navigate a PR?

A
  1. General: Does the change make sense? Does it have a good description?
  2. Most important: Look at the most important part of the change first. Is it well-designed overall?
  3. Rest: Look at the rest of the PR in an appropriate sequence.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How Fast Should Code Reviews Be?

A

One business day is the maximum time it should take to respond to a code review request.