About one class/function per module

Peng Yu pengyu.ut at gmail.com
Mon Nov 2 08:11:28 EST 2009


On Mon, Nov 2, 2009 at 3:03 AM, Bruno Desthuilliers
<bruno.42.desthuilliers at websiteburo.invalid> wrote:
> Peng Yu a écrit :
> (snip)
>>
>> I prefer organized my code one class/function per file (i.e per module
>> in python). I know the majority of programmers don't use this
>> approach. Therefore, I'm wondering what its disadvantage is.
>
> Hmmm... As far as I'm concerned, you already answered your own question:
> "the majority of programmers don't use this approach".
>
> Now, for a much more practical answer:
> 1/ having to handle thousands of files for even a simple project is a
> king-size PITA for the maintainer.
> 2/ having to load thousands of modules will add quite a lot of overhead when
> actually running the code.
> 3/ as a result, the poor guy that will end up maintaining your code will
> positively hate you. Beware : this poor guy might as well be you.

I still don't understand why it is a nightmare to maintain the code.
For my C++ project, so far so good.

I can easily change filenames (that is class name or function name), I
can easily find them, I can easily move things around, all with just
the corresponding script command. I can navigate to the definition of
class and function by vim + ctags, I can see example code that calls
the class/function. Whenever I suspect there is a bug, I can easily go
to the right level of class/function in the directory hierarchy to
write a test case to trace down the bug without having to use gdb.

Would you please let me why it is a nightmare?



More information about the Python-list mailing list