Few of my modules get over about 600 lines, and most of them are under 400 lines.
There are several reasons for that:
- I'm often working with fairly simple concepts.
- I let CPAN modules do much of the heavy lifting when I can.
- I use mostly OO these days.I, personally, would rather have more simple objects than fewer complex ones -- as simple as makes sense, but no simpler. I usually break my modules along class lines.
-
- I've found I can reuse modules easier the less they do. That means I'll write a module meant for reuse and another that either wraps or subclasses it for just the initial project if I think most of the module will be useful elsewhere but want to keep a bunch of extra stuff out of it.
- Modularity can save space when reusing code if you don't need everything from one project in another, too.
OTOH, modules which deal with big, monolithic things that are really complex might need to be big, monolithic things that are really complex. A number of CPAN modules have files that are multiple thousands of lines long. MIME::Lite is over 3k lines, IIRC. PDF::API2 has a few files over 30k lines among its supporting modules (all of which appear to be East Asian font sets). PDF::API2::Simple sits at over 1000 lines. DBI.pm is over 7k lines.
One project I've been developing and maintaining for months has a number of modules specific to it. It also has a number of modules reused from other projects. Some of those have been improved and re-reused back into the original projects. There are several modules I'm using from CPAN for this project that are 2000 lines or longer, but none of the ones I've written are more than 1000 lines. That's one of the joys of CPAN. Someone else has done many of the big, hairy modules.