JavaScript wrangler.
Check out my books!
Web API Cookbook:
https://www.amazon.com/Web-API-Cookbook-JavaScript-Applications/dp/1098150694
Modern CSS:
https://www.amazon.com/dp/148426293X
I agree that arrow callback functions don't need names, if it is a simple function of just a few lines. If there is more complex logic I prefer to extract that into a named function and pass it as the callback, e.g.
arr.forEach(doSomeStuff);
But what drives me crazy is top-level anonymous arrow functions. I mean this:
constfoo=()=>{// ... some stuff here}
I think functions like this should always have a name.
I understand Kyle's dislike of anonymous functions but I think he takes it a bit far.
I am Software Developer, currently interested in static type languages (TypeScript, Elm, ReScript) mostly in the frontend land, but working actively in Python also. I am available for mentoring.
Generally what you said is almost exactly what I tried to describe in the article. With this difference that I don't understand Kyle dislike for anonymous functions at all, his arguments like - if you have no clue how to name something, name it - todo, are for me just bizarre. And I am not joking, he is really proposing that in his book.
I vote here for commons sense, name things when it has sense to name them, and if you do, name them accurate. There is nothing worst then bad names.
JavaScript wrangler.
Check out my books!
Web API Cookbook:
https://www.amazon.com/Web-API-Cookbook-JavaScript-Applications/dp/1098150694
Modern CSS:
https://www.amazon.com/dp/148426293X
I agree that arrow callback functions don't need names, if it is a simple function of just a few lines. If there is more complex logic I prefer to extract that into a named function and pass it as the callback, e.g.
But what drives me crazy is top-level anonymous arrow functions. I mean this:
I think functions like this should always have a name.
I understand Kyle's dislike of anonymous functions but I think he takes it a bit far.
Just my opinion.
Generally what you said is almost exactly what I tried to describe in the article. With this difference that I don't understand Kyle dislike for anonymous functions at all, his arguments like - if you have no clue how to name something, name it - todo, are for me just bizarre. And I am not joking, he is really proposing that in his book.
I vote here for commons sense, name things when it has sense to name them, and if you do, name them accurate. There is nothing worst then bad names.
Thanks for the comment!
I think one of the main criticisms is that they just show up as
(anonymous)
in a stack trace, so it might make debugging harder.Honestly, that's the only issue I can think of.