|
|
Halbert wrote:
> How about Microsoft's engineers starting the whole Hungarian Notation
> convention with Windows programing.
Actually, this makes a lot of sense for C *when done right*.
The point was not to repeat in the variable name the types that you
declared to the compiler. The point was to repeat in the variable name
the types you CANNOT declare to the compiler.
If you have
int line_width;
int line_height;
int page_height;
int line_count;
int pixel_count
the expressions
page_height = line_count * line_height
and
page_height = line_count * line_width
and
pixel_count = page_height * line_width
and
pixel_count = page_height * page_height
are equally type-correct as far as C is concerned, but two are nonsense.
So you declare
int wLineWidth;
int hLineHeight;
int hPageHeight;
int hwPixelCount;
int lineCount;
Then you can write
hPageHeight = hLineHeight * lineCount;
hPageHeight = wLineWidth * lineCount; // Obvious nonsense!
hwPixelCount = hLineHeight * wLineWidth; // Looks good
hwPixelCount = hLineHeight * hPageHeight; // Nonsense!
Even picking nonsense variable names other than the notation will tell
you that it's nonsense. If you see
hSize = count * hQuantity; // Probably OK
wSize = hQuantity * count; // Probably bogus
That was the idea of "Hungarian notation". Not that you should replicate
what the compiler already knows, but distinguish types that the compiler
can't, because you're using a language whose compiler was designed to
fit into a PDP-11's memory.
--
Darren New / San Diego, CA, USA (PST)
Helpful housekeeping hints:
Check your feather pillows for holes
before putting them in the washing machine.
Post a reply to this message
|
|