4 ms·
"less code means less bugs" That really depends on how you make less code. Transforming an if condition in a ternary operator could make the code much harder m
by louhike 11y ago
"less code means less bugs"
That really depends on how you make less code. Transforming an if condition in a ternary operator could make the code much harder maintain, therefore bring more bugs. This is one example from several cases.
Sometimes a longer code means a code more readable.
- k__ 11y agoReally? I like the ternary operator more than if, but only because if is a statement in JavaScript.
- 91bananas 11y agohttps://github.com/mbostock/d3/blob/master/src/selection/html.js https://github.com/mbostock/d3/blob/master/src/selection/htm... I had to look this over the other day, I found it nearly unreadable.
- Stratoscope 11y agoThe problem with that code is partly the overuse of the ternary operator, but even more it's the wildly inappropriate code formatting and structure. Code that looks like this would be a WTF no matter what operators or statements it uses. Judicious, simple, and straightforward use of the ternary operator looks nothing like that.
- 91bananas 11y agoThe craziest part to me is if you look at the history of that file, that is the ONLY commit on that file ever. How does one write that the first time, and never have to touch it again!?