New answers tagged

1

I see your coworker's point. You went from repeating a relatively short jQuery expression to repeating an only-slightly-shorter function call. I think this is in the size range where creating a function to call repeatedly doesn't buy you much, unless the name is significantly better. You can remove more of the repetition using something like: const [foo, ...


1

In my experience, creating the function hurts readability and provides no benefit. This is only because the function is extremely short, and because it doesn't provide abstraction. If the function was longer, or more abstract than the code inside it, then I would not be against adding the function. My opinion on your C# example is the same. You have ...


1

It's possible that he is right from a pure performance point of view, although the browser can optimize that function call away (based on information like https://www.codereadability.com/performance-cost-javascript-function-call-and-foreach/). However, in this case your code seems more readable and less risky since if the key you are getting data from ("...


1

Based on my experience, I agree with you. The proposed replacement introduces a lot of repitition of the element retrieval logic and the data retrieval logic, both of which might be modified in the future and risks getting out of sync. More generally, the abstract concepts of software engineering apply regardless of syntax of specific language or tooling. ...


Top 50 recent answers are included