in reply to Is there an ideal module size or subroutine size?

Code Complete suggests that the optimum size of a method is at 100-200 lines (the data is supported by pseudo-scientific references from the 1980s, too). On the other hand, these numbers should obviously depend on the language used and on the problem solved. Mine are usually much shorter.

Refactoring only because you think your modules are too long is not a really good practice. One should think about what these modules represent and how easy they will be to fix (enormous modules may mean your subs are very tightly coupled, which is not a good thing). If, however, there is no obvious way to split the module's responsibility — it should stay as a whole despite its size.

1000 lines is rather typical and probably fine, though. Unless they are written in a very terse, domain-specific way, of course — count concepts, not lines.

  • Comment on Re: Is there an ideal module size or subroutine size?