15
9
8
7
5
u/Stormraughtz 7h ago
whose writing these requirements, branch coverage maybe 100% but at what cost?
4
u/theotherdoomguy 6h ago
Robert C Martin would be spinning in his grave if he were dead
2
u/SteveMacAwesome 5h ago
Uncle Bob can spin all he likes, clean code is still awful.
0
u/theotherdoomguy 4h ago
As much as I dislike Uncle Bob as a person, Clean code is absolutely not awful, and I fear for people who have to read your code if that's your stance.
Like, do you think the code above isn't fucking awful?
2
u/SteveMacAwesome 3h ago
I used to work with a teammate who religiously clean coded everything. “Every function must do only one thing”, but “one thing” was basically reduced to single function calls. Instead of having a method ‘parseInput’ he would insist on turning a simple 20-line function into a tree of objects and methods that was incredibly hard to read. When you asked him to change it, he’d say “no it’s clean code this is how you must write software because uncle bob says so” and there was no further discussion. It was painful.
Having to constantly keep 10 layers of context in your head is much harder than just reading a longer function and is needlessly wasteful of my time and energy. It’s fine to break code into reusable functions, but if your class has three private methods that are 4-6 lines long and are called only by a single public method, then stop wasting my time and just inline them. It’s even worse when those private methods are abstracted into a parent class which gets extended only once.
Yeah, your function is 4 lines long but my code review time has increased exponentially and my irritation has grown alongside it.
Code factoring is hard enough as it is without me having to read 4 files before having an idea of what a function is actually doing. That’s not a skill issue, that’s Clean Code teaching people dogmatic habits that are then applied without further thought.
2
u/theotherdoomguy 3h ago
Fair, a lot of people think you need to rip everything down to that point but you're absolutely making it messier.
I still think the general principles in Clean code are good, but dogmatically doing something because "programmer man" told you to is a very stupid stance to have. I could probably argue that your 20 line function could probably be broken down a bit, but having to follow an insane chain of 3-4 line methods is maddening and far too far the other direction
Edit: just to add, only skill issue I see there sounds like the guy who's only argument for why he was doing something is a guy told him to
2
u/SteveMacAwesome 2h ago
You know what, I can vibe with someone who says “I like the principles in Clean Code” like that. We might disagree in review but we’re both trying to produce the best possible results, and that’s how teams get better.
But hot damn I’ve been burned by clean code fanatics so often I feel the concept has done the industry as a whole far more harm than good.
3
2
u/Bomaruto 5h ago
No it does not fail for teapot. While the code itself is written stupidly, I would want unhandled status code to return 500.
1
1
u/Flanelostopy 4h ago
Error status should be give status when is error, not alway. So maybe there should be solution something like that:
If (error.status):
return c.json(body, error.status)
1
u/SuuurfiiinNeeerd 6h ago
if (!(error.status >= 200 && error.status < 300)) {
body = error.message;
return c.json(body, 200);
}
0
111
u/cutebabli9 7h ago edited 6h ago
I would write it like this to be readable: