TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

How to Do Code Reviews Like a Human

6 点作者 paladin314159超过 7 年前

2 条评论

flavio81超过 7 年前
So far the best article i've read on code reviews; one that finally considers the human side. Well done!
BeetleB超过 7 年前
I&#x27;ve been thinking about this very topic in the last few months - mostly due to recent experiences with a coworker. In general I noticed that I was feeling the reviewer is being overly annoying&#x2F;picky, but couldn&#x27;t quite place why until a few weeks ago. It&#x27;s about how the person does code reviews (and has the same behavior in other team interactions).<p>There&#x27;s some overlap with the contents of this submission. I&#x27;ll give some examples:<p>&gt;&quot;Why did you code it this way?&quot;<p>(There could be more specific variants: &quot;Why did you make this a class?&quot; &quot;Why did you give it this name?&quot; &quot;Why did you place it in this file?&quot;, etc).<p>This is a poor question to ask. I found I would spend time thinking about it and justifying it, which is draining when asked for every detail in the code.<p>The underlying issue is this: We are having a conversation amongst equals. The role of a reviewer is not a superior position to the developer. When asked this question, I do not know <i>why</i> it is being asked. If I give a detailed answer, I am putting in a lot of effort whereas he is not, which makes the conversation very asymmetric. He is &quot;taking&quot;, but is not &quot;giving&quot;.<p>I recently read the book &quot;Influence&quot; by Cialdini. One lesson I learned is that the notion of reciprocity is deeply ingrained in us. Thus his taking and not giving was, deep down, bothering me (even though I did not know the cause).<p>Arguably, in this context, you could argue that it should not bother me. However, consider the cognitive load of coming up with all these answers, whereas it is <i>trivial</i> for a reviewer to ask these questions.<p>The reviewer needs to put in the effort and find flaws - not just sit back and have me explain it all to him.<p>From now on, I think my response will plainly be &quot;Because it solved the problem&quot;.<p>Alternative question, which is a little better:<p>&gt;&quot;Why did you use approach X instead of approach Y?&quot;<p>This a bit better, because at least I now am getting a hint on what his concern is. But it&#x27;s still making me defensive. I still need to justify it, analyze approach X with approach Y, and think about it.<p>From now on, my response will be any of:<p>&quot;I did not consider Y&quot; (if true)<p>&quot;I did not see any benefits of Y over X&quot; (if true)<p>&quot;Overall, the pros of Y did not outweigh its cons&quot;<p>(etc).<p>Ultimately, the issue is: Reviewer thinks Y is a better way to do it. Instead of saying it outright, he is being very indirect and hinting at it. So I now have to play a game of guessing why he thinks so. He is trying to be clever&#x2F;polite by thinking up a bunch of questions that will lead me to his conclusion, but almost always those questions get answers he is not expecting, and this gets long winded.<p>&gt;&quot;Your approach X has these flaws&quot;.<p>Useful if I was not aware of them. If I am aware of them, then, um, so? Am I supposed to respond to that?<p>For any complex solution, there will <i>always</i> be tradeoffs, and hence there will <i>always</i> be flaws.<p>I think my standard response to that will be:<p>&quot;Yes. Yes it does.&quot;<p>&gt;&quot;I see that you used approach X. I think X has the following flaws (lists them out). Have you considered Y, which has these benefits (or absence of flaws)? Would you agree that Y is a better approach?&quot;<p>This is how people should ask questions in reviews. I don&#x27;t have to guess what the person is leading up to. No uncertainty in my mind.<p>I&#x27;ve been reading books about communications in the last year, and they generally say &quot;Ask questions if genuinely curious. Ask questions to verify assumptions&#x2F;judgments you have made. Do <i>not</i> ask questions to lead the other to a conclusion.&quot; (Or rather, state your perspective and then ask questions like the question above).<p>At a younger age, we were told about the virtues of the Socratic method. It was ingrained in me and even now I involuntarily use the method on others when I&#x27;m trying to get them to see something. I can tell you from my experience: It&#x27;s a bad idea and a habit I need to get away from. I wrote more about it elsewhere and can expand on it if anyone is interested.