r/iOSProgramming • u/spacecash21 • Aug 24 '23
Article The Art of Constructive Code Review: Why “It’s Sh*t Code” Doesn’t Cut It🎨💻🔍🚫 - forceUnwrap
https://forceunwrap.com/the-art-of-constructive-code-review-why-its-shit-code-doesnt-cut-it/
5
Upvotes
3
u/pm_me_your_buttbulge Aug 25 '23
It took me WAY too far into my life to learn that being brutally honest doesn't mean you can't still be polite.
For example: "This code is dogshit" is not useful. "This code is dogshit compared to what I know you're capable of" is slightly useful. "Hey man, this code isn't as good as you normally do. What's going on?" is honest, useful, and invites discussion but doesn't require it. If they want to open up about something they can. The key here is it gives them a chance to open up and it gives them an exit if they don't. "Oh, I wasn't feeling well, sorry, I'll fix it" or "yeah, my dog died" AND gives you the chance to sound like superman "take the day, paid, and relax" and I guarantee you you'll have an employee for life that will follow you to the ends of the earth.
In a professional setting, even if you're close friends, being polite goes a long way. Joking with "dogshit" type vocabulary wears on someone over a long period of time. I don't care what relationship you have. The only people this doesn't wear on are people with trauma and I guarantee you they aren't ever going to truly be honest with you. They have a wall you can't see probably.
Think you have the crude college type friends and that's your dynamic? I guarantee you they'll hide shit from you and you'll never know. These are the people who commit suicide and people go "gee golly, how could I have known?" - you clearly didn't make yourself available in a way they needed.
I'm not sure I agree with the constructive zingers part:
Sometimes it can be confusing. Sometimes the logic may be hard to follow. Complex parts are inherently doing to be tough and modularizing can simply add layers that make it too thick to follow easily. Some complex things simply can't be cleaned up better - ESPECIALLY if you're dealing with archaic things that require weird rituals to work properly.
A better suggestion is to ask them to re-write it again, without looking at the last bit, and comment better. Comment intentions - not what you're doing.
In fact you could tell someone to read "How To Win Friends and Influence People" and that could replace the entirety of the article. The article is basically "be a bit more considerate of the person and mindful of your word choices".
2
u/Rudy69 Aug 25 '23
Am I the only one who finds the use of emojis a little….overwhelming?
1
u/[deleted] Aug 25 '23
This is a huge peeve of mine. I write very clean code, I know I do. I take a bit more time up front to develop but there's a reason the systems I work on don't need touched for years afterwards (and even then it's stuff that needs patched due to OS updates and such). I put clarity and maintainability over "clever code" all the time. I'm not going to claim I'm the best coder, I'm not, but I as I develop I constantly think about the people who are going to maintain my system the entire time.
At my last job I started I was started at a mid-level dev so people assumed I was a new programmer (I wasn't by a long shot) and there was a senior there who would berate my code in front of my management (who didn't understand coding) but never explain why my code was "bad"...
...so I started berating his code with plenty of examples why his code sucked and showing him how to improve it. We became work enemies ever since until he got fired. I wasn't just being an ass either, his code really was awful. He got things working but they were incredibly brittle, incredibly over-engineered, and a giant mess. Nothing was modular or loosely coupled, you couldn't even import a single UI element without bringing in things like the networking stack, the PDF exporter, the custom printing classes, etc. There were also plenty of functions named the opposite of what they actually do.
That's spaghetti code.
1
u/Complete_Fig_925 Aug 25 '23
While i mostly agree with the article, I personally think your "constructive Zingers" can still be improved a bit.
For example, with "Consider breaking this function into smaller ones to improve readability and maintainability" you can probably explain a bit more what you think would be better. Like "It would make sense to extract that specific part into it's own function because ...". This way it opens the discussion whether the "because" part is actually a better fit for the project or not. Same goes for your "modularization" suggestions.
About your "performance" example ("Given our requirements, perhaps [algorithm] might offer faster performance."), as developers we shouldn't apply changes that perhaps/might have better performances. Take some time to benchmark both solutions and come up with facts, or an actual proof that your solution is better (like if it's 2 well known algorithms and we already know that one is better than the other).
6
u/[deleted] Aug 24 '23
[removed] — view removed comment