ASP.NET 控件的命名约定
可能的重复:
ASP.NET 控件的命名准则是什么?
是否有关于 ASP.NET 控件元素的命名约定/样式的标准指南。我见过一些开发人员在文本框前加上 txt 等前缀。是否有任何应该遵守的标准?
Possible Duplicate:
What are the naming guidelines for ASP.NET controls?
Is there a standard guidelines as to the naming convention/style that asp.net control elements should be named. I have seen some developers prefixing textboxes with txt etc. Are there any standards that should be abided by?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以使用 ISO 标准命名约定或 CMM 级别约定。
就像函数名称“Add”
变量名称“strQuery”
控件名称“btnSubmit”
类名称“Common”
命名空间“Sanjog.Web”
公共属性名称“UniqueId”
私有变量“_uniqueId”
希望这就是您正在寻找的。
You can use ISO standard Naming convention or CMM level convention.
like Function name "Add"
variable name "strQuery"
Control Name "btnSubmit"
Class Name "Common"
Namespace "Sanjog.Web"
public Property Name "UniqueId"
private variable "_uniqueId"
Hope this is what you are looking for.
像“txt”这样的前缀对于使用 VB6 的开发人员来说更为常见,或者是从使用 VB6 的开发人员那里学到的。在真正面向对象的环境(例如 .NET)中,没有必要为项目添加前缀来指示其类型。然而,这样做完全是个人喜好的问题,只要保持一致即可。
Prefixes like "txt" are more common with developers who came up through VB6, or learned from developers who came up through VB6. In a truly object-oriented environment such as .NET its not as necessary to prefix items to indicate their type. However, doing so it entirely a matter of personal preference, just be consistent.
控件的命名没有官方标准。
实际上,命名约定只是为了您的方便,以便它可以重复使用,而那些将编辑它或试图理解它的人对他来说并不是什么大问题
现在进入正题,一般在公司级别遵循命名约定
,即有些使用文本框的前缀(如 textBoxName 、 textBoxPassword),有些使用 txt (如 txtName)。一切都是对的。
只是团队中的所有开发人员都必须遵循相同的要求,并在整个项目中保持相同的状态。
There is no official standard for naming of controls.
Actually the naming convention is only for your convenience so that it can be reusable and some one who will be editing it or trying to understand it would not be a big deal for him
Now coming to the point Generally Naming conventions are followed in company level
i.e some use the prefix of textbox (like textBoxName , textBoxPassword), some txt ( like txtName). Everything is right .
It is just that all the developers in a team must follow the same and the same to be maintained through out the project.
MSDN 已对此进行了介绍 -> MSDN 命名指南
(下面是链接页面的摘要,太长了,无法将所有内容都展示出来)
不管怎样,只要从事项目的每个人都遵循相同的约定,那么无论约定是什么,你就可以开始。
MSDN has it covered -> MSDN Naming Guidelines
(follows an abstract from the linked page, too long to bring everything over)
Anyway, as long as everyone working on a project follows the same convention, you're good to go, whatever that convention is.