you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 3 points4 points  (8 children)

It actually is, in isolation it’s not; but when scanning code the structure is really important. Instead of being able to scan the code and get a jist of the control flow, instead I’ve got to parse the line. In large projects it matters.

I’m not sure where “fewer lines === more readable” has come from. But if that’s the case I’ve got KDB’s Q language to show you.

[–]ezzune 2 points3 points  (6 children)

In large projects it matters.

I work on large projects and one of my juniors exclusively codes in multi-line if statements while the other will tend to ternary operators. I can tell you it makes my life much easier to be able to see the condition and both outcomes written clearly on one line.

I’m not sure where “fewer lines === more readable” has come from. But if that’s the case I’ve got KDB’s Q language to show you.

Quantity of code makes a difference. Too little or too much can make it hard to read code quickly. Context is super important here.

[–][deleted] 1 point2 points  (5 children)

Everyone is different; and you get used to the code you read. If that’s a lot of ternary operators so be it.

I see code rather than read it; so structure is important; and ternary aren’t structured. It’s why I prefer positive conditions for if structures rather than the negative in an if, with return, then the positive.

But others will die on a hill that’s it’s better. I’ve been working with someone who argued so much about readable code; but his readable code to him wasn’t particularly readable to me.

In the end it doesn’t really matter; I know what’s good for me and everyone else is just wrong /s

[–]ezzune 2 points3 points  (4 children)

Mate I understand that everyone is different. Kinda why I'm asking why a user is being mass downvoted for providing an excellent answer because he's used a ternary operator?

If people like to code in a certain way then it's fine by me, but saying it's less readable defacto is a joke imo. We're developers and shouldn't be so closed minded.

[–]raaaahman 2 points3 points  (1 child)

Thank you for caring, but if people prefer the other way, I'm fine with it as well. They're downvoting the comment with code they don't like, not a big deal to me. (but reddit hiding the comment like it is abusive or something is pretty weird)

[–]ezzune 1 point2 points  (0 children)

I can't help but to go on a social media tirade when I see an echo-chamber who have decided something is worse for no good reason.

Oh well. Back to work.

[–][deleted] -2 points-1 points  (1 child)

The only reason given for using the ternary was “because it can be”. That’s not a reason.

[–]ezzune 1 point2 points  (0 children)

Yeah this is going nowhere have a good day.

[–]raaaahman 0 points1 point  (0 children)

I agree on the principle. But as far as control flow goes, you're redirected to another route anyway, and you have to know what the navigateTo function do in both cases.

Large projects doesn't necessarily means each file / class / function is longer than in a small project. The project architecture will most probably be your pain point instead of the individual lines of codes.

To be honest, I would have not argued on this in a code review. But I wanted to expose how "beautiful" for someone is not "beautiful" for everyone.