By Any Other Name

First let me apologize right up front to whomever is reading this. God and I were talking about computer programming this week. That means that I’m now about to talk to you about computer programming. I’ll try to make it accessible for those of you that aren’t programming-afflicted, but I can only go so far.

The good thing about talking to God is that he can give me insights into the minds of other people. That’s actually pretty valuable to me, because like a lot of computer geeks I’m often baffled by the apparent lack of rhyme or reason for the actions of my fellow humans. As it turns out, this even applies to other programmers. I commented to God that I’ve never understood the attraction of “Hungarian Notation” and he showed me what was missing in my analysis.

For the non-programmers that have foolishly continued to read along, I’m going to try to explain this without going into too much detail, or even hardly any at all. Computer programs can generally be considered to be mechanisms to take some input, process it, and produce some output. The input is data (and often also instructions, but that’s more detail than we want to get into). In order for the program to describe how it’s going to manipulate the data from input into output it uses containers called variables, each of which gets its own name. They are called variables because what they actually contain varies from one program run to the next. Hungarian Notation is a system of naming variables in computer programs with leading characters that serve as mnemonic reminders of what type of data is in the variable. The reason it’s called “Hungarian?” The guy that invented it was originally from Hungary, it made the variable names look kind of foreign, so, other people started calling them Hungarian. Well, you asked. Or at least I imagined you did.

The thing that’s always bothered me about this notation is that I’ve always found it to be making variables hard to read, and hard to pronounce, while imparting to their every invocation one of the things about them that is the easiest thing to look up: Their data type. Again for the non-programmers out there, most every programming language either demands that you declare a type for every variable or at least allows you to declare one whether or not it’s required. So it’s trivially easy to pop up to the declarations and look up the type if you need to know it.

Or at least it is for me.

What God pointed out to me is that while most programming languages require a declaration, they’re generally pretty lax about where you can put the declarations. I adopted very early in my career the discipline of always putting them in a standard location. It makes it really easy to look them up. But as God points out, many programmers have rather chaotic habits about their variable declarations. They don’t always cluster them together, they don’t lay them out for easy readability, they don’t even always give them sensible names or names that are easy to pick out in a random section of text. In short, they make looking up their origins hard to do, so they try to pack the information that is required at declaration into every use of the variable. That way they just have to find some instance of it, rather than the originating instance.

What they did is they discovered that they had made something hard to do, and instead of simplifying that thing, they covered for it by making a bunch of other stuff hard to do as well.

So, like I said, I often find myself baffled by the things other people do. Even people that are generally pretty logical.

RSS feed


No comments yet.

Sorry, the comment form is closed at this time.