4 ms·
As a professional, I got tired of being mean, so I switched to a different review style where I ask questions instead. I would still ask a lot of questions. Th
by skybrian 8y ago
As a professional, I got tired of being mean, so I switched to a different review style where I ask questions instead. I would still ask a lot of questions.
Then I started to worry that I was coming across as passive-aggressive, that these suggestions would be taken as veiled demands to fix things.
As a countermeasure, sometimes I'd explicitly say things like, "you can submit this as-is, but here are a bunch of things you might want to think about." This works ok for stylistic changes or things that aren't actual bugs.
That's not always realistic. Another trick that I think maybe we should do more in the industry is what I'd call ping-pong code review: When you get a review, either submit it if it's good enough, or rewrite it and send it back to them for review. Then they can either submit it, or do another rewrite and send it back to you.
This helps the most if there extensive changes needed, and you are a picky person who likes to have things just right. But, if it goes against company culture, you might need to make sure that people understand what you're doing and everyone gets proper credit for helping with the patch.
- dfilppi 8y agoThat's the socratic method. Far more constructive.
- mnm1 8y agoSo you want to write each feature/bugfix three times? What kind of company that's still in business does that? I worked with an engineer who would sometimes rewrite my perfectly fine pull requests and it didn't go well. What an absolute waste of time and company resources. Maybe if the code is utter shit and it can't be fixed by the original engineer, you would need to fire him and rewrite it. Otherwise I can't see any situation where a business would be ok with such a massive waste of resources.
- skybrian 8y agoIt depends what you're comparing to. Doing a lot of round trips during code review is extremely costly, particularly when you're separated by many time zones and you only get one round trip a day at best. Getting a patch in can take many days. Telling someone to change the code (and maybe having them misunderstand) is often less efficient than changing it yourself, due to the extra round trips. If you're sitting right next to each other, some other technique like pair programming is going to be a lot faster.
- mnm1 8y agoYou bring up a good point about changing the code. I wouldn't want the reviewer changing the code himself and not getting reviewed again. But even if it was reviewed again, I would still find it problematic as the reviewer might make changes that are unnecessary and detrimental to the code base based solely on his opinions. For example, he prefers to use front end templates vs. backend or prefers to break up classes that should stay together, etc. Most code review issues that come up are a matter of opinion and it should be up to the author to change or not to change the code. If the reviewer feels so strongly about a change, he should submit a different PR in addition and it should be evaluated separately. I can't think of anything more enraging than coming in and seeing your reviewer rewriting your perfectly good PR simply because he wants to do it his way. At that point, I wonder why I even wrote a PR in the first place. Why not have this asshole write all the code then?
- skybrian 8y agoYeah, so in the end it's all about the relationship between the programmers, and as I've said, this can be tricky. If you neglect that it's not going to work. For example, if you're sending a patch to the owner of the code and they are known to be very picky, maybe it won't be considered an insult to rewrite it, since in the end it's their project and it saves a lot of back and forth? Or maybe it's a team where they have gotten used to it? Believe it or not, starting from a patch that actually works is actually pretty helpful and does save time compared to starting from scratch.
- mnm1 8y agoI'm OK with sending a patch or pull request back to the author in any circumstance and using the author's work as a base for said patch/PR makes complete sense to me. The problem I've seen is when the reviewer takes it upon himself to make these changes directly in the current PR without giving the original author a chance to change or defend his code. This is exacerbated when said changes take an entire day or two of the reviewer's time and are so extensive that the original work submitted becomes irrelevant. This wastes the reviewer's time which could be spent on other things instead of rewriting something that already works and has been done and it wastes the author's time because it essentially discards his work. You're right, it is definitely about the relationship between programmers, but I think some ground rules would help in cases where the relationship is unclear or the programmers work async remotely.
- ensiferum 8y agoYou don't think that rewriting someone else's patch would be considered rather arrogant? I've worked with a guy who's attitude to most things was "OK, let's submit this for now, I'll rewrite this later". I found that to be rather demoralizing, why would anyone bother to put in their best work when it's just not going to be good enough for this "god of programming". I agree with the approach of asking questions and making comments like "some things to consider with this approach". Generally speaking I find that code reviews are invaluable, but it takes some practice and good language skills to find the right "style" and wording in order to appear constructive vs. bossy know it all.
- skybrian 8y agoYes, I agree that there is a risk of offending people this way and you need to put some effort into smoothing it over. Programming is often a people problem. I've only done it a few times where I was the project owner, and I apologized in advance for being overly picky. There was also good reason for it since we were many timezones apart.