circa75 Home | About circa75 | Articles | Links | Contact Us

Posted by gustav at 07:01PM, Monday, December 08th, 2003

Half-Assed Hungarian

Okay, this is geeky, and probably only of interest to a few programmers who hate their jobs. You know the so-called Hungarian style of naming variables? Then read on.

(Hungarian is the idea that you prepend your variable names with a bunch of junk -- a character for type, another for scope, etc. In the old days, when a lot of languages had character-limits on variable names, this took up a lot of your space, and the solution was to then strip out the vowels in the meaningful part of the name, which ended up with these strange consonanty names that could look like they came from an Eastern European language.)

In Java, a few retards occasionally use a lameass form of Hungarian variable naming where they prepend variables with m_ for "my" to denote instance or local variables (because they don't realize they can, or obstinately refuse to, use the more standard this.variableName construct that Java comes with to specify an instance variable, and don't realize that the way scoping works lets you have a this.variableName and a variableName in the same method (like a setter), referring to two different things), and maybe s_ for Strings, etc. Now, I admit to occasionally naming a variable something like sId, where I need a String representation of a value that would normally be a number for some strange reason, but that's to remind me that that's something that shouldn't be a string. It's redundant to name a variable s_FirstName -- because, what, you might store that as a float instead?

Anyway. At work, I had to fix a bug in a Java class that our consultants created. So I'm going through it, and cleaning it up to conform to Sun's coding style guidelines, because I get nauseous looking at the strange mixtures of spacing and bracing styles that the various consultants employ. While doing this, I find this boolean, which is named m_DidWork. It's in this method that probably should be a constructor, but isn't. But is named like one -- starting in uppercase; this in itself is a violation of Sun's guidelines. As is the class name starting with a lowercase character. Anyway. Initially, I think that it's local to the method, and at the end the code will set the instance variable didWork to it. I'm wrong. It's an instance variable, not a local one, and there is also a didWork boolean, although there's no documentation of the difference between the two (or anything else, for that matter. JavaDoc is more of a theoretical practice to these people than a process to reduce coding expenses). I notice that the method I'm working on only sets m_DidWork, the value of which is never read, and only returns didWork, which is hard-coded to always be false.

So, to summarize: this code uses a half-assed version of Hungarian naming, but to defeat the purpose, which, in this case, would be to differentiate in scope between two variables so you don't screw up and use the one you don't mean to. Here, the code differentiates in the name, but the variables are at exactly the same level, and they're both effectively useless because, well, the code sets one but never uses it there or elsewhere (and isn't subclassed), and returns the other one, which it only sets when it's initialized. And I can't tell whether that's intentional and pointless (because the consultants are inept), or just a retarded oversight (because the consultants are inept).

Truly, this is half-assed Hungarian.
circa75 Home | About circa75 | Articles | Links | Contact Us

All content copyright © 2001-2009 the owners of