4 ms·
The problem with callbacks is they are not about reusability — they force you to organise your code around I/O and not around your app logic... hence the names
by andreypopp 13y ago
The problem with callbacks is they are not about reusability — they force you to organise your code around I/O and not around your app logic... hence the names like wtfFriendAction.
- Skinney 13y agoThere 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.
- andreypopp 13y agoIt's like you didn't read my comment — how functions like wtfFriendAction help reusability?
- Skinney 13y agoIn 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.
- deleted 13y ago[deleted]
- andreypopp 13y ago> 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