Please No Hungarian Notation

One of the old die-hard hobbies is Hungarian notation and using it results in horrendously unreadable code:

var dlg = oData as FormEditAlarms;
Color nForeColorConnected = SystemColors.WindowText;
var l = new List<ServerData>();
ServiceHostTreeNode(string strText, int nImageIndex, int nSelectedImageIndex)

So why using it? Why?!

Let’s look at advantages of Hungarian notation:

  1. The symbol type can be seen from its name.
    In all modern IDEs hovering the mouse over a variable shows its declaration that clearly states the type. And this does not matter in dynamically types computer languages.
    If you use vim more often than Eclipse (me too) then I’m going to ask you: why do you need to know a symbol type? I suppose it matters so you’d declare a proper type variable or a parameter to manipulate with it, right?
    So if your symbol name is text, you would try assign it to an integer? And pass selectedImageIndex as a parameter of a vector type?
    My point is: a proper name gives a clear indication on what a symbol is, including its type.
    This advantage is false.
  2. The formatting of variable names may simplify some aspects of code refactoring.
    Really?! May? Or may not?
    This advantage is questionable and therefore cannot be true.
  3. Multiple variables with similar semantics can be used in a block of code.
    This implies that variables with different type but the same semantic need be distinguished by its type. Alright, name them differently. But it does not mean that all other variables must follow this notation.
  4. Variable names can be easy to remember from knowing just their types.
    What is easier to remember: nImageIndex or imageIndex? tv_list or treeViewList? strText or text?
    Some cryptic abbreviated word or a familiar and recognizable term?
  5. It leads to more consistent variable names.
    This one is really pulled out of the Mariana Trench. It does not!!!
    oData and oServerData are consistent, right? Wrong! serverData and serverData are.
  6. Inappropriate type casting and operations using incompatible types can be detected easily while reading code.
    How about using the compiler warnings for that? Too high-tech?

Enough said.

Don’t use Hungarian notation. It has NO advantages. And makes your code unreadable.