Coding Notation Changes?!

Actually, this is a Rant. For years I’ve gotten used to seeing things like objThis and m_strThat and knowing exactly what variable or object I would dealing with… I’ve used an approximation of what is known as “Hungarian Notation” among Geeks, but the fact is that it was easy to see nWoot and know it was an Integer. But now I’ve been hearing that you shouldn’t use Hungarian Notation anymore… it’s frowned upon for .NET applications, it’s no longer a slick way to code, and everywhere I look people seem to agree.

I. Will. Not. Comply.

Know why? Because it’s going to take years to break this decade long habit. I’ve never been one to have a multi-file application with variables consisting of a, b, and c. I use i or n for For Loops, but otherwise I’ve always had at least some sort of descriptor on each of my variables. When I started coding for a living I started to become a bit more formal and using str for Strings and sz or lpsz of lpctstr to denote string pointers. nSomething become common for integers; fSomething for floats. You get the picture.

A few days ago I saw in passing a Blog posting about the “new” way of writing code. They linked to an MSDN Article that has a number of different guidelines. Long and short of is it that you shouldn’t have any type identification in properties or fields. Use Pascal capitalization for everything except function parameters so for background color use BackgroundColor unless it’s passed into a function as a parameter, in which case it’s backgroundColor.

Simple, right? Except for a fundamental number of problems: what’s local and what’s member lever, at first look? yeah, no way of knowing because m_ isn’t allowed either. What is the type is the object that you’re looking at? Use IntelliSense, because you won’t know otherwise. Class or Struct? You don’t get to know that either: C should no longer be used to denote a class name. And then there’s the length of these fields and objects: everything in each of these documents tells you that they should be verbose. So all of that time you save while coding in .NET will be eaten up by having to type 25 letter field names? Bah!

It’s no required to write code like this… after all, it doesn’t change how the applications are compiled into MSIL. If anything, it’s strictly for humans sake because it’s supposed to make the code more readable. Sure, you can read it like a book, but how can you debug it? I would think that each and every time a new field is shown you’ll have to go digging to see what type it is. You’ll know it’s “Position” but will you know if it’s an integer, float, double, Point, or Rectangle without jumping to the declaration of the object at hand…

I know what will happen. The same thing that happens every time Microsoft changed their natural keyboard layout. The first release was great. Then they took the inverted T (for the cursor key layout) and made it a diamond; I refused to use it. Other people must have felt the same way because they went back to the inverted T, but the new keyboard had it much sharper slope. After that release they took the delete key and made it huge; they also moved the Home/End/Page Up/Page Down keys into a different layout which caused all types of chaos… I fought it for a long while but I eventually gave in and changed my habits to support the new layout. Similar stuff happened with how the directory tree of Windows has been layed out over the years: a while ago I just gave up fighting and let Windows install software wherever it wanted to, instead of being concerned about it. It became obvious that conforming was sometimes a bigger benefit than being right.

Same thing will happen here, I’m sure. I will eventually get used to the new style and will start to code that way, at least to some degree. Even thought Hungarian Notation style is more useful and I’ve been using it for so long… As an experiment, I wrote the Plug-Ins feature of SharpMt to follow the new formatting scheme as an experiment and because that code is open for other people to read and I think it’s god awful. But I still thought I’d try it.

But I don’t like it… not at all.

3 thoughts on “Coding Notation Changes?!”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.