Hungarian notation (was RE: variable naming...)

Delaney, Timothy tdelaney at avaya.com
Wed May 2 06:45:59 CEST 2001


> Sometimes, though, type-related inflections are
> needed to distinguish things that would otherwise
> have exactly the same name. For example, Object
> Pascal code for the Mac abounds with things like
> 
>   type
>     FooHandle = ^FooPtr;
>     FooPtr = ^FooArray;
>     FooArray = array[0..9999] of Foo;

Very true (oh, how I remember this ... although it was MacPascal, not Object
Pascal ;)

However, there are three things for this particular case:

1. This is not Hungarian. It is very obvious what each of these are.

2. This is dealing with memory addressing, in particular Handle-based memory
management (which is completely different to Handles on Windows for those
who don't know, and was a lovely system for reducing memory fragmentation on
low-memory systems without virtual memory).

3. These are type definitions, not variable declarations.

#2 and #3 combined makes this a perfectly reasonable and *good* thing to do.
There are also arguments for naming variables in a similar manner, because
it is a description of the *function* of the variable (i.e. this is a
pointer to something - you will probably need to dereference it to use it,
this is a handle to something, you will definitely have to lock it in place
before passing the deferenced pointer as a parameter to a function ...).

Tim Delaney




More information about the Python-list mailing list