最佳实践为C#GUI命名约定?

编程入门 行业动态 更新时间:2024-10-12 16:30:18
本文介绍了最佳实践为C#GUI命名约定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

图形用户界面,无论是书面的还是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命名约定?

本文发布于:2023-11-12 11:05:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581314.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:GUI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!