your feedback to my first project please

D'Arcy Cain darcy at druid.net
Wed Jan 11 14:14:35 EST 2012


On 12-01-08 02:46 PM, patrick at bierans.de wrote:
> Thanks for the feedback!

You're welcome.

>> D'Arcy wrote: [code examples]
> But I will keep some of my underscores for "private" attributes and methods.
> And I googled: "dim" was basic. I know too many languages and start mixing
> the keywords - shame on me. ;)

No problem but don't overuse the underscores.  It starts to look like
Perl.  The parameters to the methods and the local variables in the
methods will not pollute your namespace.  The only area you need to
concern yourself with is module level object references.

 >>> import mymodule
 >>> print dir(mymodule)

that's the list you need to be concerned with.  You will see that a lot
of names are already private.  In the case you present I don't think
that anything there was private that is not already private based on
what it inherits from object.

> Good Eye: I wrote the tests after coding - I know that this is the wrong way.
> I just wanted to start coding and after some time I decided that I shoud have
> some test cases. This is no real TDD - true. ;) I'll do that right next time.

This is the number one lesson you should take to heart from this.

> After thinking about it: Yupp. You are right. Having written tests to check
> "private" attributes really hurts one's pride. ;)

And you don't want to.  The test cases should make sure that public
objects and methods act as specified.  That's what allows you to
refactor any time you want.

-- 
D'Arcy J.M. Cain <darcy at druid.net>         |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.
IM: darcy at Vex.Net



More information about the Python-list mailing list