Re: another PyDO alpha

Jacob Smullyan <[email protected]> Tue, 17 May 2005 00:52:32 -0400
Newsgroups gmane.comp.web.skunkweb
Message-ID <[email protected]>
On Mon, May 16, 2005 at 09:41:35PM -0600, Jonathan Ellis wrote:
> I'm just starting to get into the code -- I'm curious, what is the 
> philosophy on underscores on PyDO members?  I'm sure there's some principle 
> on which do and don't, but it escapes me.

A single underscore loosely denotes that the method is private or
protected, without clearly distinguishing between levels of privacy.
Generally speaking, users of the class should ignore members that
begin with an underscore; subclassers aren't so restricted.  

The _new() and _create_field() methods in PyDO are implementation
methods that you might conceivably wish to override, and so are
protected (in a Javaesque sense of that word).  Users wouldn't
normally directly use them.  The class attribute _fields contains
bookkeeping data for the class; I think you probably wouldn't need to
access it directly in a subclass, and hence it is more private.

I did name the class attribute flag "_guess_tablename" with a leading
underscore, even though it only exists to make customization possible.
This isn't inconsistent with the policy stated above, but
"use_attributes" is a flag with a similar role and is public-style.  I
might add an underscore to use_attributes; I don't expect people will
bother to change it much.  

The policy as stated is actually pretty standard, but what may be
confusing, apart from the inconsistency I noted, is that PyDO has lots
of class attributes, including some that are meant for declarations
but that aren't very useful for data access (because the metaclass
processes the declarations and stores the result privately), so they
have corresponding access methods.  (For example, "fields" isn't
private in any sense, but once you have a PyDO subclass, calling
MyPyDO.fields only tells you what you've declared, not what the real
fields, including inherited ones, are; you have to call getFields() to
get the real deal.  I could change this with metaclass magic, but all
in all it seems more transparent to me that the declarations be
accessible later through the same attribute they were declared with.)

Cheers,

js

> 
> -Jonathan
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by Oracle Space Sweepstakes
> Want to be the first software developer in space?
> Enter now for the Oracle Space Sweepstakes!
> http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click
> _______________________________________________
> Skunkweb-list mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/skunkweb-list
> 

-- 
Jacob Smullyan
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFCiXiQuqamFyFXXLIRAsIoAJ9Na/HY+PBVN30x0tkq+5K0tZ4jqwCgylbm
JgDo7s8NnaDFQzxQqkdfRYk=
=0Xk4
-----END PGP SIGNATURE-----