I do a fair amount of Java programming, but it has always been for servlets and JSPs, so I’ve never had a need to do any Swing GUI programming. I’ve long been curious to learn more, so I recently picked up Herbert Schildt’s Swing: A Beginner’s Guide.

I haven’t finished it yet, but it’s been quite good — one of the better books of this type that I’ve read. No complaints at all about the technical aspects of the book. The thing is, in all of his code examples, he’s using a variant of Hungarian notation for his Swing components:

JLabel jlabBass;
JSlider jsldrBass;

I haven’t actually seen Hungarian in quite some time — mostly because I think many programmers (especially me) are kind of lazy. Remembering to consistently prepend an appropriate prefix to variable names is tedious.

Now for those of you younger programmers, Hungarian came out of Microsoft and was essentially some rules for creating a prefix in front of all your variables. The prefix would tell you something about the type of that variable. The idea being that you’d easily know whether two variables were compatible types by the prefix on them.

As computers got faster, there was enough horsepower available so that IDEs could start detecting variable types in real-time; so, as you code, the IDE can alert you to type incompatibilities (usually with the little squiggly red underline popularized by Microsoft Word’s auto spell-check).

Which brings me to my question: Is there still a place for Hungarian notation in a world with type-savvy IDEs? I probably would have written those variables like this:

JLabel BassLabel;
JSlider BassSlider;

On the other hand, I do see the benefit to consistent use of Hungarian. I think it actually makes sense for code that’s going to be printed, as in Schildt’s book. In paper form, Hungarian makes the code quickly readable at a glance.

So, do you think there is still a place for Hungarian notation? Do you use Hungarian where you work?