[Tutor] Help(!) with OOP/Composition from "Learning Python"
Kent Johnson
kent37 at tds.net
Fri Oct 21 21:44:08 CEST 2005
Andrew P wrote:
> On 10/21/05, Kent Johnson <kent37 at tds.net> wrote:
>>You can also think of classes very pragmatically, as another tool available to
>>organize your code, just like modules and functions.
>
> I realize after all these reposnses that I should have mentioned that I do use
> classes to do exactly that.
>
> But I have the nagging feeling I still have it all upside down and inside out.
> Writing a bunch of objects that are supposed to interact in dynamic ways at
> runtime with nobody leading the band, and all. Maybe if I'm not writing a
> a library or framework I shouldn't worry so much.
Hmm...there are probably some programs like that...maybe a large framework like Twisted. Most of my use of classes is fairly prosaic, just a way to organize code so it makes sense. Class instances are usually related by simple containment in a loose hierarchy of some sort.
> For all I know people are using IDEs that let them write unreadable code that
> simultaneously allows loosest coupling between classes, and most reuse of code
> at the expense of readability. Giant jellyfish-like automatons that are easy
> to maintain with appropriate tools. I'm still not sure that impression is
> wrong :)
Well, except for the "easy to maintain with appropriate tools" you are probably right. In fact I have the misfortune of working on a system like that right now. Without appropriate tools, whatever they may be.
>
> I do my best learning by reading good examples. I imagine most people do.
> There is just no substitute for understanding what somebody else has done well,
> tip to tail. I am just mistrustful of something so hard to puzzle out.
This thread has a few suggestions:
http://groups.google.com/group/comp.lang.python/browse_frm/thread/da095d94c77fe2c7?q=code+examples&hl=en&
Kent
More information about the Tutor
mailing list