Control Naming on Forms

Another classic hard problem:  how do you name controls on a form?  Do you follow a certain guideline?  What are the options?

  1. Hungarian Notation
  2. Full name
  3. Something Better?
Hungarian notation in it's true form tries to indicate something about the variable, not just it's type.  If you have a set of variables dealing with database values such as indexes that name all such variables idxIndexName.  This is a nice convention, especially in hostile (non Visual Studio) environments.  Consider this usage in JavaScript and SQL.

Full name is popular in WinForms and ASP.NET forms.  Something Like CustomerDataGridView.  While very descriptive, it's also very long.  I've tried this format and I find it unsatisfying.

Something Better?

From the Irritated Vowel Naming Convention page, we have modified Hungarian.  Instead of using the full name, like above, we use a short prefix like ui or ux to indicate a User Interface or User eXperience element.

At first I rejected the Irrated Vowel naming suggestion out of hand.  But now I've been reconsidering it.  Why?

This convention avoids problems with changing control types (textboxes to drop-down lists, or simple text box to some uber textbox, or text box to date picker, for example), and groups the items together in intellisense. It is also much shorter than most Hungarian conventions, and definitely shorter and less type-dependent than appending the control type to the end of the variable name. I will use generic suffixes which allow me enough freedom to change them around.
The freedom to change controls without changing names is pretty useful.  In the absence of any compelling naming convention, the one with the most pragmatic points wins.  So I'm going to try the modified Hungarian in my next project and see how I like it.

About

[Insert Witty Saying Here]