One-garian Notation


Beware all those who read the following, they are the irreverent ramblings of a heretic …

Religious beliefs are so tricky. For the true believer no alternatives can be possible. Their minds are closed.

I was once a devout believer of Hungarian notation. Charles Simonyi was my guiding light. My strings were all szDecorated, and I was at peace with the world.

But, as with all religions, there were those who would not accept the one true way. Hedonistic forces held sway at Microsoft, and .Net naming conventions repudiated Hungarian notation!

I was thrown into confusion, and my world disintegrated around me! Had I been led astray? Were my beliefs really so faulty? All those years, for nothing?

And then I noticed something incredibly suspect about the preachings of the anti-Hungarian notationalists. Despite their adamant claim that Hungarian notation was evil, they in reality espoused a corrupted form of Hungarian notation themselves!

Yes, it is true, the anti-Hungarian notationalists are inconsistent! They call for the abolition of Hungarian notation, while preaching the following doctrine:

– The names of interfaces must start with the letter I.
– The names of generic types must start with the letter T.

Why was this? How could they ask me to give up one faith for a new one that contradicted itself?

And then one day my turmoil was resolved! In a moment of revelation the great nerd in the sky spoke to me: “Do not follow the preaching of others! Create your own religion, be true to yourself, and say to hell with the forces of conformity. It will be a rocky road, and you will be held in contempt, but you will discover an inner peace that not even Hungarian notation gave you.”

I call my new religion “one-garian notation”.

It can be considered to be a further development (or corruption, if you will) of the .Net naming conventions, where not just the names of interfaces and generic types have specific one-character prefixes, but the following as well:

– The names of constants must start with the letter C.
– The names of delegates must start with the letter D.
– The names of enumerators must start with the letter E.

That’s it. One-garian notation (named because it is based on one-character prefixes) is the same as .Net naming conventions, plus the use of three additional one-character rules, for a total of five.

I do not expect my new religion to attract any followers. In fact, I expect to be scorned and ridiculed. Such is the lot of heretics.

Please have a nice day.


6 Responses to “One-garian Notation”

  1. There is probably an auto-da-fe in your future.

    Once I was traveling to Damascus and the finger of Dennis Ritchie touched me out of the sky. Since then I never use anything but i,j,k and n as variables.

    • For some strange reason that reminds me of a very old Dilbert strip. (Wish I could find it again.)

      Dilbert and Wally and a new programmer are eating lunch, and the new programmer is boasting: “When I started programming, we didn’t have any of these sissy ‘icons’ and ‘windows’. All we had were zeros and ones — and sometimes we didn’t even have ones. I wrote an entire database program using only zeros.”

      Dilbert: “You had zeros? We had to use the letter ‘O’.”

      • Thank you very much, jockothy!

        I had that strip (in black and white – “when I started programming we didn’t have any of these sissy colors”) taped to my wall for many years. But then it got lost during a move to a new office.

        By the way, I didn’t actually remember the text verbatum – I remembered enough of it, and was able to find the correct text several places on the Internet.

  2. 5 Steve

    Hungarian notation is old, but that doesn’t mean other decorated notations are “corrupted Hungarian”. The term Hungarian denotes a specific set of decorations, which are appropriate for a particular set of languages.

    The truth is that different decorations do different jobs. Another old notation is that where “p” indicates a parameter and “l” indicates a local. In C++, you often see “m” for member as well. These work well because in a function or method, it often makes a lot of sense for the same name to apply to several identifiers. For example in a setter, it makes sense for the parameter (value to set) to have the same name as the member (value being set) – even the method will probably have the same name, prefixed with “Set”.

    “C” for classes looks more like Hungarian, but is different. Statically typed languages like C++ and C# (usually) know when an indentifier with the wrong data type is being used, so that compiler checks make any benefits not worth the clutter – but C family languages are gramatically sensitive to whether something is a type or not. That can cause parsing issues that are confusing to both the compiler and the programmer. In Object Pascal there is much less reason to use a “C” prefix – the grammar isn’t ambiguous.

    That said, in templates (the C++ nasty functional sublanguage for compile-time metaprogramming) suddenly the “C” *is* a kind of Hungarian-style prefix.

    Any system of decoration has costs and benefits. The primary cost is clutter. Whether the benefit outweighs the cost depends on the type of decoration and the language you are using, and to some degree on other aspects of your coding style and the kind of project you are working on. And ultimately, any system is just an imperfect means to the real goal – making the code more readable and maintainable – and must never be allowed to defeat that goal. Which is the long way of saying “use your brain”.

    As for those people who say the most important thing is for everyone to use the same style – I quite strongly disagree. Different styles tell you who wrote which code, which is a good clue for understanding that code – kind of like getting to know how particular indie game developers think.

    In short – I’m a strong believer in the way of “there is no one true religion”.

    OTOH, if god had intended identifiers without underscores, he wouldn’t have created acronyms 😉

  3. 6 grnat

    It seems to me that prefix notations are nearly obsolete with the advent of intellisense, syntax coloring and other sorts of features. In fact, prefixes kind of get in the way. For example, if you prefix all your classes with the letter “c” a particular letter, then in the end you end up typing the letter “c” many times with no real gain. Perhaps with interfaces there is still a need since its often useful to be able to discern ones concretes from the interfaces on the base class line.

    With the proper structuring of namespaces, the contextual mechanism works quite well. If one shifts the internal paradigm a bit, the idea of textual symbol input is giving way to menu driven symbol syntax. As the machines get faster and faster, alternate styles of symbolic input will start to be practical, maybe something like a statistically driven symbol generation. I’ve seen it attempted before, but it was pretty slow and the visual representation was a bit weak. Couple in the vast power of GPUs and maybe we would see something really interesting.

    To be quite honest, I’m really, really tired of typing. I think that if I could stack my finger movements into a linear progression of movement, I would discover I had circumnavigated the globe a couple times already.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: