Do I always have to write "self." ?
Samuel A. Falvo II
kc5tja at garnet.armored.net
Sun Apr 30 14:44:51 CEST 2000
In article <300420001008012011%pecora at anvil.nrl.navy.mil>, Louis M. Pecora
>Isn't this called something like "Hungarian" variable naming? It has
Hungarian Notation is what it's called.
>use g for global variables: gChannel, gSocket1, etc. I thought it was
>an aberration. Ugly! A suffix would be much more readable: Channelg,
>Socket1g etc. But even then...
Suffixes are infinitely HARDER to read, because the type moniker merges into
the name of the object itself. To use your example above, "Channelg." Is
Channelg the English word "Channel" followed by a 'g', or is it a word in
some other language? I can't tell. Also, you wouldn't say things like
"Channel global" would you? In most English speaking countries, people
would tend to say "Global Channel" instead. Hence, gChannel.
It also defeats the whole purpose of Hungarian notation to begin with. The
idea of Hungarian notation is to allow the programmer to determine the type
of object the symbol refers to immediately. And since we tend to read from
left to right, it makes sense to place such information left-most (e.g., to
The place where suffixes are best applied are in actual data types (versus
variable names). For example, "size_t" in ANSI C. It's the Size Type.
However, having a variable that represents the count of the bytes in an
object would be cbObject, not Object_cb.
I always use Hungarian notation when it makes sense to. For example, if I
have a function in C that accepts a string and an explicit length argument,
I would write something like this:
uint32 WriteData( void *buffer, char *pString, uint32 cbString )
This tells me that WriteData() takes as parameters a buffer, a pointer to a
string, and the number of bytes in the said string. I fail to see how this
is somehow hard to read. :)
KC5TJA/6, DM13, QRP-L #1447
Samuel A. Falvo II
More information about the Python-list