Tuesday, June 16, 2009

Hungarian Notation Diatribe

Sometimes I think coding standards are like fashion standards. Often, styles and notation are fawned all over one year and then criticized and passe the next.

The current target of the code fashion moguls is Hungarian notation. That's the idea of prefacing a variable or object name with the type of variable or object.

According to what I've researched, this is no longer needed because of Intellisense and cute little popups when you hover over code telling you all about the source of the entity. So, if you still use code conventions like btnEdit for an button with an Edit caption, you're some sort of reprobate.

Interestingly, Microsoft stays away from this debate in code samples. To them, a Label is forevermore Label1 in sample code. I can kind of understand that since being an ex-Softie I remember the reluctance to embrace 3rd party"standards".

Personally, I still use a type of Hungarian and probably always will. I don't see why it's such a bad thing to name a variable boolActive when it's a boolean flag or intChildren when it's an integer variable. Who does it hurt? It makes hard-printed code easier to read and it's easier to "digest" a block of code with its intent. The name of the variable or object has no impact on the stack or heap so what does it matter?

Stupid code standard dweebs. Get a real job.


Anonymous said...

I totally agree, for all of your reasons. I also am Hungarian my parents brought me here when I was 18 months old. :-) I'm also a VFP-Clipper-dBaseIII programmer. Did you know another famous Hungarian wrote the original MS-Word, Charles Simomyi. info@MisterEPhoto.com

Anonymous said...

...now that I think of it, Hungarian notation was actually invented by the past Chief Architect at Microsoft, Charles Simonyi, who's now a millionaire and a past "Recreational Astronaut" ISS visitor.