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

Stephen Hansen me+list/python at ixokai.io
Fri Jul 9 01:16:08 EDT 2010


On 7/8/10 9:37 PM, Steven D'Aprano 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.

If that is really true, then it belongs as one module, regardless of
size -- I don't believe there's any certain count where you should draw
this line. Now, once you get up to say, 5-10 KLOC, I find it hard to
believe that everything there really does belong together and there's
not a substantial subset of code which really belongs "more" together
then it does with the surrounding code. That would then lend itself to
be a new file in a package.

But that can happen at 1 KLOC too. But then it can still be 5-10 KLOC
which, to me, fits perfectly together still. Its just more likely the
higher the count that you have subsets that would benefit from logical
separation.

-- 

   Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 487 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20100708/e3b01232/attachment.sig>


More information about the Python-list mailing list