Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There is a difference between callbacks and lambdas. Nothing forces you to provide a lambda as a callback. If that lambda will only ever be used once, then it's ok as long as it's short and easy to understand what it does.

If that function is required multiple places, you make a proper function out of it, and pass that function instead of a lambda.

Callbacks allow for abstractions like map, filter, reduce... Used properly, they can actually increase reusability instead of prohibiting it.



It's like you didn't read my comment — how functions like wtfFriendAction help reusability?


In this small example it doesn't, getFriendsById however, does. I would imagine that wtfFriendAction could be used multiple places though.

wtfFriendAction is additionally a very, very poor name. It should be called "addFriendToFriendList" or something. Another thing is that the author himself states that the function doesn't actually makes sence, hence the ugly name.


> Another thing is that the author himself states that the function doesn't actually makes sence, hence the ugly name.

That's the point — using callbacks you end up with functions which do not make sense...

Edit: spelling




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: