in reply to Re^2: Perl Code Quality
in thread Perl Code Quality
Make sure there aren't a lot of anonymous functions that are hard to reuse.I use a lot of anonymous functions, and that doesn't make it hard to reuse them. On the contrary, I do it to easier reuse code. I use it as an local abstraction technique, and we agree on that abstraction is good, while I at the same time don't want to pollute the global namespace for a function that would only be confusing there since it only has value where it is. In the future, if that piece of code has value outside the lexical scope it's defined in, it's easy to move it out. Sometimes these functions are closures, sometimes they're not.
Edit: I'm not arguing with ihb, I'm adding to the above argument.
See also Is it possible to create a sub exclusive to a sub?.
Further, function generators often allow a level of abstraction that "ordinary" programming techniques don't: the ability to build code from data, not just operate on data. Look at Specializing Functions with Currying for a simple example of how higher-order functions can promote reuse and remove redundant code.
I agree with ihb that anonymous functions (well, let's say "lots of coderefs") are a good sign, not a bad one. I'm sure there are exceptions, but functional abstraction isn't the kind of thing I can easily imagine a mediocre programmer doing.
--
F
o
x
t
r
o
t
U
n
i
f
o
r
m
Found a typo in this node? /msg me
% man 3 strfry
|
|---|