Why NOT only one class per file?

John Nagle nagle at animats.com
Thu Apr 5 12:51:10 EDT 2007


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.

    Interestingly, PHP breaks this model; PHP programs are web pages.
They may be on to something.

				John Nagle



More information about the Python-list mailing list