Naming convention of controls

  • Thread starter Thread starter kevininstructor
  • Start date Start date
K

kevininstructor

Greetings,

I am in the process of creating naming conventions for VB.NET controls i.e.

CheckBox -> chkShowThisOnStartup
ListBoxt -> lstSomeList


What I am looking for other developers input for Window.Form controls and
what they are using for naming controls.

Note: On MSDN I have found a good deal on standards for non-visuals but not
controls.

Thanks,
Kevin
 
The debate rages on... but anything that is private to your class can be
named in any way that you like. Hungarian notation is discouraged, and the
VB style control naming syntax is a variation of that. However, if your
controls are publicly visible or accessible from derived classes then they
should follow Pascal casing, since they are treated as public fields.
http://msdn.microsoft.com/library/d...en-us/cpgenref/html/cpconnamingguidelines.asp

If you're controls are being classified as "private", then I still find
myself using the good ol' VB naming style (Label = lbl, Button = btn, etc.).
And for those instances where there may be no corresponding VB control I
would just guess based on past VB experience.
 
I think you should not use your own naming conventions either for public or
private methods unless you have a very good reason to do so.
Naming conventions are well documented and you should get used to them
regardless of the scope of your procedures or controls.
I find somewhat difficult having two naming conventions to remember.
 
Tim Wilson said:
The debate rages on... but anything that is private to your class can be
named in any way that you like. Hungarian notation is discouraged, and the
VB style control naming syntax is a variation of that. However, if your
controls are publicly visible or accessible from derived classes then they
should follow Pascal casing, since they are treated as public fields.
http://msdn.microsoft.com/library/d...en-us/cpgenref/html/cpconnamingguidelines.asp

If you're controls are being classified as "private", then I still find
myself using the good ol' VB naming style (Label = lbl, Button = btn,
etc.).
And for those instances where there may be no corresponding VB control I
would just guess based on past VB experience.

Except for Button = btn.... VB naming conventions say to use cmd for the
first 3 letters of a button's name.

Visual Basic Coding Conventions
http://msdn.microsoft.com/library/d...vbconcodingconventionsoverview.asp?frame=true

....more specifically,...

Object Naming Conventions
http://msdn.microsoft.com/library/d...vbcon98/html/vbconobjectnamingconventions.asp

Not sure where "btn" was born.... probably some web dev. We use a very
slightly modified version of the doc(s) above. Since we don't use any of the
controls where a 4 or 5 letter prefix is defined (5 letter prefix? sheesh
<g>), we've removed those from our version of the docs.
 
Yeah, I think that "btn" seeped into my programming culture over the years.
Probably because it seems to make more sense with the naming of the .NET
"Button" control.
 
My vote is PLEASE loose the btn, chk, ect. and adopt a modern standard
where-in you just post fix with the control type.

CheckBox -> myCheckBox
ListBoxt -> myListBox

The only thing I don't like about this naming conventison is that in
order to wire it up in the code behind, there is a protected member
variable. I don't know about you all, but I prefix all my member
varaibles with _myVariable (no, not m_MyVariable, but this is just a
style preference) so, I may argue in this case you should add the _ to
your control names so the member varaible naming convention is not
violated.

CheckBox -> _myCheckBox
ListBoxt -> _myListBox

What are everyone's thoghts on that?
 
Again, it just comes down to preference, or whatever standard the business
that you work for has decided upon. Microsoft does not put forth standards
for code that is private. I know that standards are a good thing but what is
"good" depends on who you ask. So unless the business that I work for
mandates a private naming policy (which very well could be the case), I
would just do whatever makes my life easier in the long run. I work
primarily in C# and by default the controls are marked private.
 
I disagree with that a bit. I learned a standard with a company I was
employed with years ago, and modified it slightly for my own taste.
I now use that "standard" in all my personal code. However, at my current
job, we have several different areas to service and a multitude of
languages,
using software previously written by other companies and modified by other
support personnel...
So I end up using whatever standards have been used previously for similar
code.
Actually, I looked up the "standard notation/conventions" listed in our
company specs, and found them to be last updated in 1990...

I hate trying to decipher other peoples notation (especially when variables
are named a, b, c, d etc!!), but I haven't got time to rewrite the entire
thing to any standard... so it has to remain a bit of a mess.. :(

Just my tuppence
____________________________________________
The Grim Reaper
 
Back
Top