Writing Comments
「何を言うか」と同じくらい「どう言うか」が重要です。コードレビューは対人コミュニケーションです。
1. Ask, Don't Command (命令せず、質問する)
命令形は相手を防御的にさせます。提案や質問の形にしましょう。
❌ Bad (Command/Personal)
"This code is too hard to understand. Rewrite it."
命令形。主観的。
✅ Good (I-Statement/Question)
"This logic seems a bit complex. Would extracting the validation into a helper function make it easier to read?"
「私にはこう見える」というIメッセージ+具体的な提案。
2. Review the Code, Not the Person
❌ Bad
"Why did you do this? It's wrong."
「あなたが」間違っているように聞こえる。
✅ Good
"I see the intent here. However, using a global variable might cause race conditions. What do you think about passing it as an argument?"
コードと意図についての議論に集中。
3. Label Your Comments (ラベルを付ける)
全てが修正必須ではありません。重要度を明示しましょう。
- [Nit] (Nitpick): 修正してもしなくても良い。
- [Suggestion]: 提案。議論の余地あり。
- [Blocker] (or no label): 修正必須(バグや重大な設計ミス)。