开发者

C# Naming Convention (Title vs. Name)

开发者 https://www.devze.com 2023-02-21 11:27 出处:网络
I have a series of classes that implement a Title (or Name) depending upon which word you semantica开发者_如何学运维lly choose.Is there a C# naming convention standard for Title vs Name?Both are prett

I have a series of classes that implement a Title (or Name) depending upon which word you semantica开发者_如何学运维lly choose. Is there a C# naming convention standard for Title vs 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 consider MemberInfo.Name and IIdentity.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".


This may not be a C# question but a common sense question applicable to many other areas beyond computers:

class Author
{
  string Name{..};
}

class Book
{
  string Title{..};
}
0

精彩评论

暂无评论...
验证码 换一张
取 消