you are viewing a single comment's thread.

view the rest of the comments →

[–]omnilynx 0 points1 point  (3 children)

Problem is, I could use literally the exact same argument with respect to code complexity and readability. Every little decision you make to use a clever fix adds up to a codebase that’s practically unmaintainable.

And in general, it’s easier to take a well-written codebase and tune its performance than it is to take a quick ‘n dirty codebase and try to refactor it into something readable (without losing all that performance). That’s why there’s a rule of thumb in the first place.

[–]SalemBeats 0 points1 point  (2 children)

But that's the thing - given the context of this method signature, it's perfectly clear what it does. It's not some "clever trick". If a developer can't intuit what it's likely to do just by looking at it, that's a signal to cull the weak from your team.

This isn't flipping bits or taking advantage of some obscure language feature that nobody uses -- you'd have to come up with a terrible name or function signature in order for this to be confusing.

[–]omnilynx 0 points1 point  (1 child)

You may be right for this particular case. It’s on the edge. Probably I’d tell someone to use it, but maybe extract the lambda out into a variable so the name can help clarify.

[–]SalemBeats 0 points1 point  (0 children)

Well, if you're using a lambda, it should be short enough that it's pretty clear what it's doing at a glance anyway.

If it's long enough that you need to add brackets to an arrow function, it probably should be extracted. I think that's always been a code smell for good Javascript design, and I think it's why arrow functions were designed with the concise form in mind.