共用方式為


Hungarian Notation (Again)

Cyrus is having difficulty parsing out the example given in Simonyi's original article on the subject. I've blogged about this before, but it's worth reiterating the main point of my earlier post.

It's somewhat unfortunate, because the example that Simonyi chose happens to be a rather bad example of Hungarian notation, though, arguably, it serves well to illustrate Simonyi's point about "dimensional anaylsis."

There's a really simple rule we can use to figure out whether or not we're using Hungarian notation correctly. If the name of the variable denotes nothing more than the language type of the variable, then we're using it incorrectly. If the name of the variable reflects how it's being used in the program, then we're using Hungarian notation correctly. In this sense, we can think of Hungarian notation as acronyms applied to variable names.

As an exercise, you might want to take Simonyi's example, and correct the usage. In particular, see if you can't think of a better prefix for the computed hash value. perhaps "hsz", or maybe simply "sh"?

By the way, there's a potential bug in Somonyi's example that's implied by the use of Hungarian notation. There is an extern integer declared as "bsyMac" in the code. This is a current maximum value within a collection. PsySz computes a new bsy, but doesn't update bsyMac. It should, either directly or indirectly.

 

Rick

Currently playing in iTunes: Book Of Liars (Live) by Steely Dan

Comments