« Vom Suchen, Finden, Verlieren und Suchen | Main | St.Georg Cafe Koppel »

Dienstag, Januar 20, 2009

JoS on Hungarian

Joel ist mal wieder sehr unterhaltsam und lehrreich unterwegs: "Making Wrong Code Look Wrong" differenziert (apps hungarian vs. systems hungarian) die häufig einseitige Sicht auf die Ungarische Notation und bricht einen Stab für sinnvolle Anwendung derselben - schön ist mal wieder zu lesen, wie halbverstandene Richtlinien für jahrelangen Ärger sorgen - ein Problem, dass ich kenne :-)

The dark side took over Hungarian Notation.

Nobody seems to know why or how, but it appears that the documentation writers on the Windows team inadvertently invented what came to be known as Systems Hungarian.
Somebody, somewhere, read Simonyi’s paper, where he used the word “type,” and thought he meant type, like class, like in a type system, like the type checking that the compiler does. He did not. He explained very carefully exactly what he meant by the word “type,” but it didn’t help. The damage was done.
Apps Hungarian had very useful, meaningful prefixes like “ix” to mean an index into an array, “c” to mean a count, “d” to mean the difference between two numbers (for example “dx” meant “width”), and so forth.
Systems Hungarian had far less useful prefixes like “l” for long and “ul” for “unsigned long” and “dw” for double word, which is, actually, uh, an unsigned long. In Systems Hungarian, the only thing that the prefix told you was the actual data type of the variable.
This was a subtle but complete misunderstanding of Simonyi’s intention and practice, and it just goes to show you that if you write convoluted, dense academic prose nobody will understand it and your ideas will be misinterpreted and then the misinterpreted ideas will be ridiculed even when they weren’t your ideas. So in Systems Hungarian you got a lot of dwFoo meaning “double word foo,” and doggone it, the fact that a variable is a double word tells you darn near nothing useful at all. So it’s no wonder people rebelled against Systems Hungarian.

Man kommt über die Wikipedia-Seite an anderen historischen Dokumenten vorbei, die sich ebenfalls gut lesen lassen - Linus ist zwar ein Diktator, aber eben auch lustig:

Encoding the type of a function into the name (so-called Hungarian notation) is brain damaged - the compiler knows the types anyway and can check those, and it only confuses the programmer. No wonder MicroSoft makes buggy programs.

Erstellt von tixus um 7:48 PM Kategorien: Software + Java
Powered by
Thingamablog 1.1b6