views:

120

answers:

3

What naming conventions do you use for user interface elements (including dialog boxes)?

Controls: I use [Descriptive Name][Control Type] (e.g. OKButton, MainTableLayout)
Windows: I use [Descriptive Name]Window (e.g. SearchWindow, CustomerListWindow)

Occasionally, I will shorten a control type name if it is still legible ("Grid" instead of "DataGridView")

What are your conventions, and why do you use them?

+1  A: 

My conventions are practically identical to yours. My reason to include the type in the name is to indicate that it's a UI object we're talking about not something tangible. Eg. a UI button not a real-world button.

Frederick
+1  A: 

I do pretty much the same as you, except I use 3-4 letter abbreviations such as Btn and Lbl for controls.

I use them just for convenience and maintainability, and so that when Intellisense pops up I can immediately pick out the option I meant, e.g. FirstNameTbx instead of the property FirstName. It doesn't save much time in the long run, but it still helps, and most people I work with expect it to be like that anyways.

Brandon
A: 

I have used both the hungarian notation (btnOK, grdCustomers, etc) and a slightly different version where everything is just ui(uiOK, uiCustomers).

I like having the type in front because when using an IDE you can quickly type in something like "btn" of "ui" and it will filter to your ui elements.

On one hand, I prefer the "ui" approach over hungarian because my code behind shouldn't really care what type my element is. Plus if I change grdCustomers to a list (lstCustomers), I have to change a lot of code.

On the other hand, the downside to prefixing "ui" to everything is that you get a lot of duplicates ( you have a textbox for customer name and a label for that textbox, bot would be something like uiCustomer).

Jacob Adams