Why NOT only one class per file?

Sherm Pendley spamtrap at dot-app.org
Thu Apr 5 07:11:35 EDT 2007


Bruno Desthuilliers <bruno.42.desthuilliers at wtf.websiteburo.oops.com> writes:

> Sherm Pendley a écrit :
>
>> It's a stylistic thing, nothing more. 
>
> A bit more than just 'stylistic' IMHO. It's a matter of
> convenience. Having to manage hundreds of files each with a dozen
> lines of code is a PITA.

Yes, but the pain in that case comes from having hundreds of trivial
classes, not from the way in which the source for them is organized.

> Having to retype the same import statements
> in hundreds of files is a PITA - and a good way to waste time and
> forget something when one has to fix these import statements (yes,
> even with the appropriate tediting tools). I wouldn't call such
> considerations "nothing more than stylistic".

Neither would I. But then, I would describe the existence of all those
files as just the symptom - the real problem being the design that needs
all of those hundreds of trivial classes in the first place.

Granted, I know very little of Python. It may be the case that Python
encourages the use of hundreds of "little classes" - and if that is the
case, then I agree, storing each one in its own file would be rather
absurd.

I'm more accustomed to writing classes that tend to be larger - hundreds
if not thousands of lines each, or more - and in that case, storing them
one per file is a reasonable way to organize one's sources.

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net



More information about the Python-list mailing list