[Python-Dev] Organization of ABC modules

Nick Coghlan ncoghlan at gmail.com
Sat Jan 26 16:01:38 CET 2008


Raymond Hettinger wrote:
>> but if Guido likes the idea of a standard naming convention (such as 
>> the ABC suffix) for classes that use the ABCMeta metaclass, I'd 
>> certainly be happy to go through and update the affected classes and 
>> the code which refers to them.
> 
> A prefix would be better.

I initially thought that, but found the suffix to be the least annoying 
of the ideas I had for denoting abstract base classes. To try and give 
some idea of how I came to that conclusion I've listed some of the other 
ideas I had below (again using the numeric stack as an example).

INumber
IComplex
IReal
IRational
IIntegral
   Using a simple 'I' prefix annoys me for cases like the last one where 
the class name actually starts with an I, and 'interface' is a bit of a 
misnomer for abstract base classes anyway - they have a lot in common, 
but they're not the same thing. This is also an existing convention for 
things like zope.interface, so probably not a good idea to adopt to mean 
something else.

ABCNumber
ABCComplex
ABCReal
ABCRational
ABCIntegral
   I find using the ABC acronym as a prefix ends up with too many 
capitals together at the start of the word and it becomes far more 
obtrusive than it needs to be. The main thing about these classes is 
what they represent - the fact that they're ABC's, while still 
significant enough to indicate somewhere in the name, should be of 
secondary importance.

AbcNumber
AbcComplex
AbcReal
AbcRational
AbcIntegral
   This one bugs me mainly because I don't like lowercasing letters in 
acronyms just to try and fit in with a camel-casing scheme. It's just ugly.

After those 3, I couldn't think of any other prefixes that were both 
short and likely to be an effective mnemonic for identifying ABC's - 
Abstract is too long, Abs is far too easy to associated with 'absolute' 
instead of "Abstract base class", etc.

Which lead me to the idea I actually used in my earlier post:

NumberABC
ComplexABC
RealABC
RationalABC
IntegralABC

That way the normal class names are still front and centre, with a short 
annotation tacked on to the end to say "oh, by the way, this happens to 
be an abstract base class".

I'm not sure any more discussion will be particularly useful though - 
any convention that gets adopted is going to be by Guido's fiat and will 
need to suit his aesthetic sense rather than mine :)

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-Dev mailing list