Hungarian notation

I love Hungarian notation.

Michael Kaplan has written a nice post on this, with some interesting insights. I particularly agree with (2); I also use Hungarian notation, but all the time. My code looks like this:

//internal create.
internal Clabject(Model moOwner, PowertypePattern pp, Class clClassFacet, Object obObjectFacet)
    : base(moOwner, EModelElementType.Clabject)
{
    //save to private data.
    m_pp = pp;
    m_clClassFacet = clClassFacet;
    m_obObjectFacet = obObjectFacet;

    //init.
    this.SynthesiseName();
}

I fully agree with (3), i.e. most of my team mates (and programmer colleagues) say they don’t like it, they can’t understand why I do it or what its advantages are, and they think it looks ugly. They would write something like this:
In my case, (4) is not true. None of my colleagues, as far as I know, use Hungarian notation. They would argue that the above code is OK because, as Michael points out, Intellisense and other IDE features will tell you what is what.

Then I usually ask them about the last code review session and the 5-10 pages of hardcopy code they bring with themselves, and whether Intellisense works on that. Hmmm… no. And you want to catch as many code defects as possible during code review, don’t you? Yep. So you need to know the type of each variable and parameter quickly and unambiguously, right? Yes.  So, tell me, what type is m_Owner in this code snippet:

//delete this instance from the model.
public override void Delete()
{
    base.Delete();
    m_Owner.DeleteClabject(this.FullName);
}

Is it OK to call DeleteClabject on m_Owner? That depends on what it is, right?. They will then start fumbling pages around until they find the declaration and answer my question.

It is amazing how much we work with code on paper these days…

Advertisements

2 Responses to “Hungarian notation”


  1. 1 rp 11 January 2005 at 10:38

    If the IDE supported it, even enforced it, I would use it more. Now that I have to do it by hand, it’s much less attractive. The main problem I have is that it’s not always obvious whether or how to choose the prefix. Conventions are much better when they are not ambiguous.

  2. 2 cesargon 11 January 2005 at 20:13

    Sure they are. Of course, using Hungarian notation makes no sense if it does not come with a nice set of naming conventions. One way to do it is: each time a developer creates a new class, just add the Hungarian prefix for the class to the comments on the top of the file.


Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s




Follow me on Twitter

Archives


%d bloggers like this: