In general, I hate lambdas. Seems to me like almost always,
you can come up with something more straghtforward, more debuggable,
more testable, more readable, etc. But… Please chime in with your
opinion. A few lines? Up to 10 lines? The bigger the better (can you
say “job security”?)? Bring it on!
I very rarely create lambdas explicitly, so I don’t think this has ever
come up for me (unless you’re including blocks). In general, I’d
probably
use about the same metrica as I use for methods, which is to say a
couple
of lines, unless it makes sense to be longer.
No, I’m not including blocks. Actually, the lambda that is getting me
upset is 109 lines long, is a value for a key in a hash, takes an
optional block, and is defined in a rails helper… And the problem is
that I need to add a feature that should reuse some of the code that is
in that lambda.
In general, I hate lambdas. Seems to me like almost always,
you can come up with something more straghtforward, more debuggable,
more testable, more readable, etc. But… Please chime in with your
opinion. A few lines? Up to 10 lines? The bigger the better (can you
say “job security”?)? Bring it on!
I’d say similar rules as for methods apply - maybe a tad shorter. 109
lines for a method is very long - especially in Ruby.
Kind regards
robert
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.