in reply to Module Bloat and the Best Solution

Both examples are 2 lines. Yet solution that uses a module had (at the time I last checked) more votes than the core solution that didn't use a module at all. Is it really that much easier to read the 2nd solution?

Read some of educated foo's crusades against one-liner CPAN modules here and here for a counter-argument to using small CPAN modules. Just for the record, I don't agree with the premise, but I respect the argument.

Some of these small modules have been zenned to a functional minimum and yet may deal with subtle edge cases invisibly, or in some way Do The Right Thing.

And once the code has been hidden behind the interface of a module, it doesn't really matter what it looks like. If there's a bug, it can be corrected and you don't have to do anything. You can't do that when the snippet is scattered inline repeatedly across a large swath of code. If it's too slow, it can be XSified, and still you don't have to change anything on your side.

I believe that the more you use modules, the more you can chunk things and operate at a higher level. I've used LWP::UserAgent and HTTP::Request for years, and have looked at the code for probably all of two minutes. And of the two minutes I spent, the main thing I took away was "Gee, I'm glad I don't have to worry about that."

• another intruder with the mooring in the heart of the Perl

Replies are listed 'Best First'.
Re^2: Module Bloat and the Best Solution
by shmem (Chancellor) on Nov 09, 2007 at 09:04 UTC
    If there's a bug, it can be corrected and you don't have to do anything.

    Bugs won't fix themselves. If you find a bug in, say, XML::Twig, you're extremely lucky, because mirod really cares about his modules. How many CPAN authors are as responsive as he is?

    If you you find a bug in a module whose author either doesn't care or has no time, then the bug is yours.

    You can't do that when the snippet is scattered inline repeatedly across a large swath of code.

    You wouldn't do such scattering anyways, would you? You'd factor these out into a subroutine, and fix any bugs there.

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
      Couldn't agree more with your point about bugs in CPAN modules becoming your problem. Excepting core modules, this happens a lot in my experience. I now have a growing personal collection of hacked and patched modules with fixes to significant bugs which have been reported but not yet fixed on CPAN, and that includes such well-respected examples as CGI::Session. CPAN's a great resource, you have to factor in the extra time it takes to evaluate, test, and possibly fix what you find there.