April 22, 2004
Hey, a sane coding style

I whole-heartedly concur with all that is good an geeky.

In my own code, I tend to also add an additional line under a comment for readability.. like so..

// This is a comment
//

Hungarian notation? Hate it, despise it, don't like it. It makes for long, clunky variable names that become cryptic instead of helpful half the time.

[via jeremy]

Posted April 22, 2004 09:58 PM in Java
TrackBack URL for this entry: http://www.unix-girl.com/mt/mt-tb.cgi/1205
Comments
On April 23, 2004 04:25 AM Sam added:

/*
* This isn't a comment
* it's an explanation with delusions of granduar
*/

#
On April 23, 2004 06:18 AM Aristotle Pagaltzis added:

Not only is hungarian notation awkward.. it is also a hinderance. What if you change the variable's type at some point? Search&replace? Ugh.

#
On April 23, 2004 08:03 AM kasia added:

hey, something we can agree on!

#
On April 24, 2004 12:09 AM dave added:

The notion of tagging a symbol with its type is useful only in typeless languages. E.g., if you're writing in an assembler which is perfectly willing (as it should be) to let you execute a move-long into a byte-sized datum, it's Real Helpful to be constantly reminded that it's a byte-sized datum.

Simonyi (the Hungarian in question) invented his particular type-tagging scheme (there are of course many others) when he was programming a machine that didn't even have an assembler. It was probably vital then.

On the other hand, it's a worthless piece of junk in modern programming. Why do I need to write 'int nFoo' with the 'n' to remind me foo is an integer? The presence of the work 'int' should give me a big hint (and of course most uses of foo ought to be within sight of its definition; if you've got 17 pages of code between definition and use, you've got worse problems than merely notational).

'Hungarian' adds clutter, which reduces comprehensibility. It turns code you can read (with words like 'filename') into gibberish (like 'pszFilename'). It is unenforceable by the compiler (so arrant nonsense such as 'CString pszThing' goes unchecked). It does not scale to languages having an infinite number of types (what prefix should I use for variables of my own class daves_example_class? most Windows programmers seem to punt on that one).

Interestingly, Microsoft development seems to split into two camps: the user-mode people (boo!) who think Hungarian is a good thing, and the kernel people, who don't touch it.

#
On April 26, 2004 04:52 AM Sam added:

I am not sure I agree with hungarian notation for asm, but it doesn't matter.

In modern languages it is too clumsy to work with, can it describe my polymorphic types ?

The only place I can see any use for it is in compilers and linkers for name-mangling.

It doesn't use strict, but is very similar.

#
Trackbacks