[Tutor] Naming conventions (was: Should this be a list comprehension or something?

Terry Carroll carroll at tjc.com
Fri Jan 28 19:25:48 CET 2005


On Wed, 26 Jan 2005, Sean Perry wrote:

> And now, for the pedant in me. I would recommend against naming
> functions with initial capital letters. In many languages, this implies
> a new type (like your Water class). so CombineWater should be combineWater.

I hate hate hate hate hate camelcase and will never use it.  In my book,
if the name has *any* capitals in it, the first letter is capitalized,
too.  Anything else is unaesthetic.  

To me, when I have names that are composed of multiple words (say, "rice
quantity"), I have two approaches: distinguishing the words by case 
(RiceQuantity) or separating by underscores (rice_quantity).

I never confuse classes/instances and methods, because I use noun phrases
for classes and instances (HeatedWater, VerifiedInput) and verb phrases
for the methods (CombineWater, CookRice).  I suppose I could get
confusion, for example, when the combination either a noun phrase or 
verb phrase (SoundOut: is that a name describing the Sound that's being 
put Out, or is it a method that's is tentatively Sounding Out somthing?) 
but so far that hasn't been an issue for me.

Of course in my case, I write code only for myself, so I have the luxury 
of not worrying about what Joe in the next cubicle is doing, and what Jane 
will do when she's trying to read Bob's and my code together.  So I have 
the luxury of turning my nose up at camelCase.

I should add that, the one time I made changes to someone else's Python
code for release (a minor patch to nntplib.py), I used the same case
conventions already in place in the module.



More information about the Tutor mailing list