Computer Chess Club Archives


Search

Terms

Messages

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

Author: Roberto Nerici

Date: 00:17:02 03/05/04

Go up one level in this thread


In C++ I use a fairly simple version for inbuilt datatypes but in general I
don't use it for objects. In C there are no objects so I use it for most
things...

However, I don't bother with much of the things you mention from Petzold. For a
start I never use WORD and DWORD except in Windows code that is directly to do
with Windows API calls; they're an anachronism and I avoid them as much as
possible (which is a lot!). I also don't bother with things like 'fn' for
function, or 'a' for array (a common one). Regarding strings, I use 'sz' for
zero-terminated strings, 'str' for string objects (whether MFC's CString or
STL's string - I rarely mix them in the same code).

The main thing for me is to distinguish between signed/unsigned integers, see
pointers ('p') and to avoid having to describe a variable type by other means.

By the latter, an example would be a bit of code which is dealing with a file,
where we have the file name and a handle. The name is stored as a string, the
handle as an int. If using hungarian I might use strFile and nFile, otherwise
I'd probably use FileName and FileHandle. Since the hungarian is shorter and
makes it more clear what types I'm using, I prefer it in this case.

The use of Hungarian notation is one of those computer-religous issues that
people get very worked up about. All three of the companies I've worked for have
used it, so that's how I came to use it, but I've always felt very comfortable
with it. Some people *hate* it though, and will swear that it is an abomination.
It probably doesn't help that it was named after a Microsoft guy!

Roberto/.



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.