Coding Conventions – Use your inside voice

At work I have to do some COM interop stuff. I’m looking forward to it, since that’s part of the framework that I haven’t played with yet and it’s a complex topic, so I’m willing to sink my teeth into it.

I think one of the deterrents to looking into it sooner was the SCREAMING_CAPS_NOTATION that a lot of COM objects had; all that lpzstrVariableName stuff would make my eyes glaze over too. I would quickly close the book or browser window that contained that code, shrug my shoulders and move on to something else that has instant learnablity – like Solitaire.

I realize that the SCREAMING_CAPS_NOTATION and hungarian notation were developed as guidelines because of the weak typing of C. Those guidelines presumably made the code more readable, but having only touched C/C++ a bit in school, reading sample source wouldn’t put me in the mood to look at more. In C code this would be:

state_my_learning_state_of_mind = CRINGING_IN_FEAR && MOVING_ON;

No wonder the notion that computer programming is hard prevails. It takes five minutes to understand what’s happening in a five lines of code!

Even Java wouldn’t let it die. Hungarian Notation is gone, but SCREAMING_CAPS_NOTATION is still lurking there in Java’s constants. Maybe that practice will die in Java with the birth of enums in Java 1.5. Here’s hoping. Even camel case looks weird for method names, but this is just showing my bias for C# 🙂

I find C# code and most of Java code to be more readable than the previous conventions, and I’m sure I’m not the only one. Microsoft, for one, went out of their way in .NET to eliminate those conventions. They took most of Java’s guidelines and took them to the logical conclusion. And that’s a good thing! And if it’s more readable without all that type information, why was Hungarian notation put in there in the first place?

Does anybody miss it?