I appreciate that this article highlights the value of using of named functions in functional-style code. Too often, programmers assume that “functional programming” means using lambdas everywhere, when in my experience, lambdas are actually a (very mild) code smell.
Lambdas alone are not a code smell. That is like saying Objects or Functions or even naming things is a code smell just because you can use them in bad ways. It is just to broad a statement to be useful. At best you might say that large/complex anonymous lambdas are a code smell - just like large/complex and badly named functions are. You need to be specific about code smells, otherwise you are basically saying code is a code smell.
I’m not saying that anyone should flag lambdas as a problem in code review, just that when you see one, it’s probably worth taking a second to ask yourself if a named function would make more sense.
I appreciate that this article highlights the value of using of named functions in functional-style code. Too often, programmers assume that “functional programming” means using lambdas everywhere, when in my experience, lambdas are actually a (very mild) code smell.
Lambdas alone are not a code smell. That is like saying Objects or Functions or even naming things is a code smell just because you can use them in bad ways. It is just to broad a statement to be useful. At best you might say that large/complex anonymous lambdas are a code smell - just like large/complex and badly named functions are. You need to be specific about code smells, otherwise you are basically saying code is a code smell.
Well, remember, a code smell isn’t something that’s inherently bad, it’s “a hint that something might be wrong”.
I’m not saying that anyone should flag lambdas as a problem in code review, just that when you see one, it’s probably worth taking a second to ask yourself if a named function would make more sense.