class size

Peter Hansen peter at
Tue Sep 21 20:48:11 CEST 2004

Brad Tilley wrote:
> How large (lines of code) should a class be before one should split it 
> into smaller classes? Is there a general rule on this? How many 
> functions should a class contain? Are there limits (theoretical or 
> practical) that people learning classes should adhere to?

Discussing this issue quantitiatively is wrong.  The real
concern should be about things like coupling, coherency,
readability, and maintainability.  Learn about those concepts and
work on lots of code, yours and other people's, until you have
developed an ability to judge when, in a given case, there are
"too many" lines, "too many" classes, "too many" methods.  There
are no strict rules that are useful.

On the flip side, if 99% of modules should have fewer than 100,000
lines of code, and putting 70 classes in a single module is
probably a bad idea. ;-)


More information about the Python-list mailing list