Video in progress
When you review other people's code, how do you write comments?
I criticize the code, not the person. In each comment I say why, I separate required comments from optional ones, and I also point out the good parts.
📖 Answer
As a middle, you go from receiving reviews to giving them. Bad comments here spoil the team's mood quickly.
Compare:
| Bad | Better |
|---|---|
| "This is wrong." | "Here it's findAll() and then a filter, which will be slow on 100 thousand rows. How about a repository method with a WHERE?" |
| "Why did you do it like this?" | "I didn't understand why synchronized is needed here. The bean is a singleton and seems to have no state, right?" |
| "Bad naming" | "nit: if we call it unpaidInvoices instead of data, it's clearer what the method returns" |
My working rules:
- prefixes:
nit:is optional,question:is a question, no prefix means it needs fixing; - let a linter check style, not a person (Checkstyle, Spotless), so nobody argues about commas in review;
- if a long argument goes past three comments, I call;
- when I see a good solution, I write that too: "using a
recordhere cleaned it up nicely".
Review speed is communication too. A PR shouldn't sit for more than a day without a response, and if it's big, tell the author when you'll get to it.
Sign up to mark studied questions and save your progress.