Friday, May 13, 2005

Make Wrong Code Not Compile/Inteprete

I like Joels latest article about making Wrong code look wrong. The whole shebang about making relationships as visible as possible and stuff.

I still do not like Hungarian notation and I do not agree with his assertion of the best solution.

The first reason is that it is dependent on a reader to tell an error. Everbody likes errors, and I like them best when they do not interprete/compile.

Which leads me to my second reason. The hungarian notations solves problems that can be adressed by other means as well. For instance type-subclassing. However this hasn’t deserved a mention in Joels post, which I find somewhat dissapointing.

Normally code is litered with dependencies, intricate semantics and stuff that makes it harder then to write blog entries. I’m pretty glad the less there is to worry about and the more is automatically checked. Hungarian notation introduces another layer of semantics on top of the existing complexities, I find it distracting.

The next reason I dislike Hungarian notation is that it forces you either to use acronyms in names, or waste rediculus amounts of name-estate.

I dislike acronyms in names because it is an additional inderection, with which I’m forced to deal in order not to make errors. Indirection because extensive use of acronyms ( as in hungarian notation ) leads to the code beeing litered with acronyms, and each of it means something that’s supposed to tell you something, that you have to remember in order to find out what it means, instead of telling this to you up front.

Obviously screen estate is limited, and so is name-estate. I like to spend name-estate on reasonably describtive multi-word names ( dislike commenting the obvious really, if I can avoid it with good naming ).
Hungarian notation can’t do that for me. But it can harm my ability to form good names, by introducing more bytes stacked on top of my names, and thus taking away valuable name-estate from me.

No comments: