Why NOT only one class per file?

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Thu Apr 5 15:56:49 EDT 2007


John Nagle a écrit :
> Nate Finch wrote:
> 
>> I think you're all going about this the wrong way.  There's no reason
>> to *always* have one class per file.  However, there's also no reason
>> to have 1600 lines of code and 50 classes in one file either.
> 
> 
>    It's really an operating system thing.  We think of programs as
> living in text files, manipulated by programs which are basically text
> editors.  Python has that implicit assumption.  There have been
> systems that didn't work that way, in which the program source was
> manipulated within the language environment, in a more structured
> fashion.  Smalltalk, LISP, and (wierdly) Forth environments have been
> built that way.  But it never really caught on.
 >
>    The assumption that programs are text files is deeply embedded in
> programming culture, so deeply that it's seldom questioned.  Programs
> are the last refuge of non-rich media.  You can't even embed an image
> in your program; it has to be in some completely separate file.

Having source code as text files may not be such a bad thing. Diffing, 
grepping and versioning binary files is not that easy...

>    Interestingly, PHP breaks this model; PHP programs are web pages.

Err... Actually, "web pages" *are* text files. And FWIW, in most php 
programs (at least the clean ones), the application logic is in separate 
files, and the 'rendering' code (views, templates, call them what you 
like) are seldom full html documents.



More information about the Python-list mailing list