C# 命名约定(标题与名称)
我有一系列类,它们根据您在语义上选择的单词来实现标题(或名称)。标题与名称是否有 C# 命名约定标准?
I have a series of classes that implement a Title (or Name) depending upon which word you semantically choose. Is there a C# naming convention standard for Title vs Name?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
两者都很常见。
根据我的观察,
Name
更频繁地用于具有内部名称的对象或自然具有 Name 属性的业务对象(例如人)。例如,请考虑MemberInfo.Name
和IIdentity.Name
。文件通常被认为具有“文件名”,而名称通常至少是对象身份的一部分。标题更常用于指代用户界面控制对象或自然具有标题的业务对象,例如文章。
就我个人而言,我认为标题是人类可读的东西,而名称更多的是本地范围的标识符,可能是也可能不是人类可读的。 (我并不是说该名称必须是完全唯一的,但在许多情况下,它是 - 无论哪种方式,它往往会在其使用上下文中提供一些标识)。我从概念上认为“标题”更接近于与“标签”的互换,而不是与“名称”的互换。
Both are pretty common.
In my observation,
Name
is used more frequently for an object with an internal name or for business objects that naturally has a Name property (such as a person). For examples considerMemberInfo.Name
andIIdentity.Name
. Files are generally considered to have a "filename", and Names often serve the purpose of being at least a part of the object's identity.Title is used more often to refer to a User Interface Control object or a business object that naturally has a title, like an article.
Personally, I think of a Title as being something that is human-readable, where as a Name is more of a locally scoped identifier that may or may not be human-readable. (I don't mean that the name has to be completely unique, but in many cases, it is - Either way, it tends to provide some identification in its use-context). I conceptually think of "Title" as closer to being interchangeable with "Label" than it is with "Name".
这可能不是一个 C# 问题,而是一个常识问题,适用于计算机以外的许多其他领域:
This may not be a C# question but a common sense question applicable to many other areas beyond computers: