Coding standard: Prefixing variables to indicate datatype

Erik Max Francis max at alcyone.com
Thu Jan 16 19:21:45 EST 2003


Lothar Scholz wrote:

> In fact now you have this fucking WIN32 API where you can find lots of
> places where the variable is different then the prefix. Event
> datatypes change during program lifetime - ignoring this means simply
> being a manager that has never written a really large software system.

That's one of the biggest drawbacks to Hungarian notation systems, even
if you buy them having some intrinsic value up front.  In the real
world, software changes, and in the real world, most programmers don't
bother updating the Hungarian prefixes to keep them up to date.

Ostensibly, Hungarian notation is supposed to allow you to tell the
purpose/type of a variable without having to look for its declaration
(or, in the case of assignment, where it gets bound :-).  But in real
world projects, where you can't be sure of the validity of those
prefixes, you are forced to go back and look at the declaration/binding
of the variable anyway.  So the entire purpose of the notation -- to
save you time -- is completely defeated.  In fact, it can _cost_ you
time, since if you trust the notations too much, you'll find yourself
getting compile errors -- or, even worse, runtime errors -- that require
multiple passes and debugging cycles.

> If your variables are so short that you can't imagine the name you are
> doing something wrong. I program in eiffel the whole day and we have
> method names
> like  "create_keyboard_shortcut_from_string". You read a program
> multiple times
> but you type it much less.

That seems to be another characteristic of Hungarian notation
programmers; they tend to prefer short, cryptic names.  Nothing like
having some vague idea of the type of a variable but being totally
unable to guess what it actually contains since its name is abbreviated
into completely obscurity.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ All the people in his neighborhood turn around and get mad and sing
\__/ Public Enemy
    Bosskey.net: Return to Wolfenstein / http://www.bosskey.net/rtcw/
 A personal guide to Return to Castle Wolfenstein.




More information about the Python-list mailing list