图形用户界面,无论是书面的还是WinForms的XAML,似乎我看到项目之间的最广泛的不同命名约定。对于一个简单的文本框一个人的名字,我见过各种各样的命名约定:
GUIs, whether written in WinForms or XAML, seem to have the most widely differing naming conventions between projects I see. For a simple TextBox for a person's name, I've seen various naming conventions:
TextBox tbName // Hungarian notation TextBox txtName // Alternative Hungarian TextBox NameTextBox // Not even camelCase TextBox nameTextBox // Field after field with TextBox on the end TextBox TextBoxName // Suggested in an answer... TextBox textBoxName // Suggested in an answer... TextBox uxName // Suggested in an answer... TextBox name // Deceptive since you need name.Text to get the real value TextBox textBox1 // Default name, as bad as you can get我的了StyleCop规则为我所有的.cs文件通常里面,看到别人也这样做,但是GUI倾向于打破这些规则或大相径庭。我还没有看到具体指GUI元素,而不仅仅是正常的变量,甚至是例子,将应用控制台应用程序之外的任何微软的指导方针。
I abide by the StyleCop rules for all my .cs files normally, and see others do so as well, but the GUI tends to break these rules or vary wildly. I haven't seen any Microsoft guidelines that specifically refer to GUI elements instead of just normal variables, or even examples that would apply outside of a console application.
什么是命名的GUI元素的最佳实践?
推荐答案我用文本框的老同学匈牙利... TXT,BTN的按钮,接着是广义的字,则更加具体的单词。即:
I use the old school hungarian... txt for TextBox, btn for Button, followed by a generalized word, then a more specific word. i.e.:
btnUserEmail
btnUserEmail
曾经有很多人说这样的话的妈呀那这么多年,VB6电话!但是在UI丰富的WinForms应用程序,我可以找到并修改的东西更快,因为通常的第一件事你了解一个控制它的类型,那么它的类别,然后得到具体的。尽管新的样式命名约定家伙被卡住试图记住他们命名的文本框。
Have had a lot of people say things like "omg thats so old, VB6 calling!" But in a UI Rich winforms app, I can find and modify things quicker because usually the first thing you know about a control is it's type, then it's category, then get specific. While the newer style naming convention guys are stuck trying to remember what they named that text box.
更多推荐
最佳实践为C#GUI命名约定?
发布评论