From: Steven D'Aprano on
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.



--
Steven
From: Stefan Behnel on
Steven D'Aprano, 09.07.2010 06:37:
> 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.

Well, if that's the case, then there's no reason to split it up. However,
for any module of substantial growth, I'd expect there to be some point
where you start adding section separation comments (Meta-80-#) to make the
structure clearer. That might be the time when you should also consider
breaking it up into separate source files.

Stefan

From: Stephen Hansen on
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/

From: Roy Smith on
In article <4c36a7a0$0$28647$c3e8da3(a)news.astraweb.com>,
Steven D'Aprano <steve(a)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.
From: Dave Angel on
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.
>
>
>
I don't have a number for you, but the measure I'd suggest is the size
of the documentation.

DaveA