Best Practices for UI controls naming convention

A

A.M-SG

Hi,

We are having different opinions how to name controls in our SmartClient
application.

Is there any best practice guide how to name UI controls?
Should we change the default names that IDE assigns to labels and panels
which we never refer to them in our code?

It would be greately helpfull if you can refer me to online resouces.

Thank you,
Alan
 
J

Jeffrey Tan[MSFT]

Hi Alan,

Thanks for your post.

Currently, I did not see any dedicated article regarding control naming.
Because all the controls reside in Form class, which is not a very large
naming container, we can simply use 2 characters control type abbreviation
with a meaningful word indicating usage to construct the control name. Such
as: Label(lbName, lbAddress), TextBox(tbPassword), etc...

Namespace structure and namming is more important than control naming.
"Keith Elder" provided a practice information regarding namespace
structure(using directory structure), please refer to "Keith Elder" reply
in the link below:
http://groups.google.com/group/microsoft.public.dotnet.framework.windowsform
s/browse_thread/thread/69f255519a489034/d241f40dfaeb7d32?lnk=st&q=namespace+
%22Jeffrey+Tan%22+change+rename&rnum=1&hl=zh-CN#d241f40dfaeb7d32

Hope this helps

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
M

Markus Hjärne

Hi Alan,

at our company we have adopted a scheme where we keep the name suggested by
the VS Designer when the control is created and replaces the trailing number
with a more desciptive name. For example, if we need a TextBox control
containing a name and it is initially named 'textBox1', we rename it
'textBoxName'.

Regards,
Markus Hjärne
 
O

Otis Mukinfus

Hi Alan,

at our company we have adopted a scheme where we keep the name suggested by
the VS Designer when the control is created and replaces the trailing number
with a more desciptive name. For example, if we need a TextBox control
containing a name and it is initially named 'textBox1', we rename it
'textBoxName'.
[snip]
I like your choice Markus. With intellisense in VS 2005 longer names
for objects and variables is not too much of a problem. I've begun to
use a similar naming convention such as nameTextBox, etc.

For variables I believe the variable name should tell what the
variable is as in 'bankBalance', 'index', etc.

Besides, with intellisense you get the type when hovering the mouse
:blush:)


Otis Mukinfus
http://www.otismukinfus.com
http://www.tomchilders.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top