Opinions please -- how big should a single module grow?

Roy Smith roy at panix.com
Fri Jul 9 01:30:12 EDT 2010


In article <4c36a7a0$0$28647$c3e8da3 at news.astraweb.com>,
 Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> wrote:

> This is a style question rather than a programming question.
> 
> How large (how many KB, lines, classes, whatever unit of code you like to 
> measure in) should a module grow before I should break it up into a 
> package? I see that, for example, decimal.py is > 3000 lines of code, so 
> I can assume that 3 KLOC is acceptable. Presumably 3000 KLOC is not. 
> Where do you draw the line?
> 
> For the purposes of the discussion, you should consider that the code in 
> the module really does belong together, and that splitting it into sub-
> modules would mean arbitrarily separating code into separate files.

To paraphrase Einstein, A module should be as large as it needs to be, 
but no larger.

There's no hard and fast rule.  More important than counting lines of 
code is that all the things in a module should represent some coherent 
set of related functionality.  Beyond that, I would say the only hard 
limit on line count is when common editing tools start to balk at 
opening the file.



More information about the Python-list mailing list