Computer Chess Club Archives


Search

Terms

Messages

Subject: To use or not to use Hungarian Notation, this is the question (o.t)

Author: Omid David Tabibi

Date: 18:26:18 03/04/04


Lately as I'm spending more time in Windows programming, I'm considering the use
of Hungarian Notation for coding. There are various "dialects" of Hungarian
Notation, but the "standard" one seems to be the one appearing at the beginning
of Charles Petzold's "Programming Windows" book:

Prefix	Data Type

c	char or WCHAR or TCHAR
by	BYTE (unsigned char)
n	short
i	int
x, y	int used as x-coordinate or y-coordinate
cx, cy 	int used as x or y length; c stands for "count"
b or f 	BOOL (int); f stands for "flag"
w 	WORD (unsigned short)
l 	LONG (long)
dw 	DWORD (unsigned long)
fn 	function
s 	string
sz 	string terminated by 0 character
h 	handle
p 	pointer

It seems that quite a mess is going on with integer types here:

Integers
         signed  unsigned
char     c       by
short    n       w
int      i       ?
long     l       dw

"w" standing for "word" used for 16 bit variables, which are no longer a word.
Same problem with long. And hell will break loose if you decide to change a
variable from char to unsigned char; you have to rename all the instances of the
variable from cVar to byVar!

For strings, we have:

s 	string
sz 	string terminated by 0 character

I'm confused here. Do we have strings not-terminated by 0?!


But on the other hand, Hungarian Notation can make the code much clearer. Maybe
a simplified notation would be better however (e.g., n for integers, s for
strings, b for bool, f for floats, etc).

What do you think about Hungarian Notation?

I noticed in Gerbil's source code that Bruce Moreland uses his own dialect of
Hungarian Notation. Does any other chess programmer use it also?





This page took 0.01 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.