Naming conventions for form Controls? i.e. btnExit vs. frmExit....HELP

Hi there - we are trying to come up with some standard naming conventions for our controls. I was taught to prefix the name with the control type.

Ex. Exit Button would be btnExit
Ex. Name Label woulc be lblName

I have also seen prefixing the control name with "frm" Ex. frmName.

I'm not sure where the industry is moving....but would greatly appreciate some feedback on this.

Thank you!

Kelley Bryant

[419 byte] By [KelleyBryant] at [2007-12-20]
# 1
That's called Hungarian notation, and Microsoft stopped recommending it about the time the guy who came up with it stopped working there. I do use it still sometimes for controls, but overall the recommendation is not to use it anymore.
cgraus at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 2

Thanks....so what do you use instead? We have standards for our variable names, method names, etc...but not for our controls on our forms....

KelleyBryant at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 3
Like I said, although it's not generally the 'done thing', I use Hungarian notation for controls, because if I have a button called btnAction, I'm likely to have a label called lblAction, and perhaps even an Action class, which I'm likely to call action.
cgraus at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 4
Thanks for your help...I appreciate it. We currently use the "frm" prefix for our controls when doing web apps and it gets a little confusing trying to disinguish the type of control. I was just trying to get a feel for windows programming and what the "going" standard is/was.

Thanks again

KelleyBryant at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 5
Hungarian notation was invented ages ago, when the development tools were just text editors and compilers. You hade to remember the types of your variables yourself, so you added abbreviations of the types as prefixes. You had b for bool, f for float, d for double, p for pointers, lppsz for far pointers to zero-terminated character strings etc.

That notion actually went out the window about 15-20 years ago with object-oriented programming - instead of a fixed number of types, now you can have thousands of classes. How do you prefix String, Stream and other classes that begin with Str differently? How do you do good prefixing when dealing with polymorphism?

Besides, the current modern tools let you see the types without having to use prefixing. Use readable well-descriptive names for new projects, but stay with prefixing for older systems that you are maintaining.

CodeWriter at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 6
Awesome! Thank you!
KelleyBryant at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 7

I use this.

textName

labelName

treeViewLibrary

groupBoxOption

optionTextName

optionLabelName

optionTreeViewLibrary

When it comes to controls added to form the biggest task is finding it not determining its type. Intellisense will tell you the type of the control, but it will not aid you in finding/jumping immediately to your controls without a custom naming-convention.

Hmmmm....

Maybe, a feature to group intellisense listing into 2 parts is in order. One group for anything added to the container and another one for the container.

JRQ at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms General...