2

In spite of the countless questions asked on StackOverflow and the countless articles I've researched online, I cannot find a clear answer on how to avoid using hungarian notation for a text box and it's corresponding label.

Let's say I name a text box as Username. In the spirit of avoiding Hungarian notation, what could I possibly call its corresponding label?

My only option is run with UsernameTextBox and UsernameLabel but I perceive this as being no different to hungarian notation in principle.

There are endless voices implying that I do not use hungarian notation but none are providing a single alternative.

Note: I already understand what true Hungarian notation is and yes, I'm referring to the wrong but ubiquitous use of it.

Clarus Dignus
  • 3,847
  • 3
  • 31
  • 57
  • Sometimes I use names like ebUsername, lbUserName. – Solo.dmitry Oct 31 '14 at 07:54
  • @Solo.dmitry Which is ultimately a variant of Hungarian notation. My point, in brief, is that how can one not be expected to use Hungarian notation in specific instances when no alternative exists? – Clarus Dignus Oct 31 '14 at 16:25

1 Answers1

1

If you are seeing advice to avoid Hungarian notation, I believe that is referring to naming your textbox txtUserName, and your label lblUserName. The new convention for winforms appears to be UserNameTextBox and UserNameLabel, which has the advantage of organizing all your UserName objects together in intellisense, for one thing.

I guess this would be considered Pascal or Camel casing, depending on whether the first letter of your object is capitalized or not.

Jeff
  • 739
  • 12
  • 31
  • Thank you **1)** for drawing a distinction between the Hungarian Method prefixes and the non-contracted suffix (I couldn't tell if the latter was considered a subset of the former), **2)** for confirming that, from your own experience, non-contracted suffixes is the new convention and **3)** for outlining the intellisense benefit of organising related objects. This is _exactly_ the information I required to finalise my project-wide convention _and_ it's in accordance with the official guidlines. – Clarus Dignus Nov 04 '14 at 18:00
  • Glad I could help in any way :-) – Jeff Nov 04 '14 at 18:09