dan*_*die 31 .net naming-conventions
我正在统一这些不一致的命名约定,这个问题最近让我发疯了.
在我正在使用的代码库中没有关于"ID"的约定; "ID","Id"甚至"iD"使用不一致.
****问题**:在.NET中,你们如何将"ID"大写?例如,nodeID,nodeId?FolderID或FolderId?
****编辑**:复数案件怎么样?那么我应该做"NodeIDs"还是"NodeIds"?
谢谢
Rom*_*ier 61
大写是2个字母的首字母缩略词.用户界面,IP等
"Id"是Identifier 的缩写,所以它应该保持pascal状态.
Dan*_*ant 31
微软的命名指南建议使用所有大写的2字母缩写词作为标识符(IP,IO,UI等),所以我倾向于"ID"(即使它不是首字母缩略词),因为当我读它时,我仍然说这些字母个别.
但老实说,我不认为微软知道/知道如何处理ID/Id:
ID
System.Runtime.InteropServices._Activator.GetIDsOfNames()
System._AppDomain.GetIDsOfNames()
System.Runtime.InteropServices._Attribute.GetIDsOfNames()
System.Type.GetTypeFromProgID()
System.Threading.Thread.ThreadID
System.Threading.Thread.GetDomainID()
System.Runtime.Serialization.ObjectHolder.ContainerID
System.Globalization.Calendar.ID
System.Globalization.CultureInfo.InvariantCultureID
System.Web.UI.Control.ClientID
System.Web.UI.Control.UniqueID
Id
System.AppDomain.GetCurrentThreadId()
System.AppDomain.GetIdForUnload()
System.AppDomain.IsDomainIdValid()
System.AppDomain.GetId()
System.Attribute.TypeId
System.TypeLoadException.ResourceId
System.Reflection.AssemblyAlgorithm.AssemblyAlgorithmAttribute.AlgorithmId
System.Runtime.Remoting.Lifetime.Lease.GetNextId()
System.Xml.Xpath.XPathNavigator.UniqueId
System.Data.OleDb.DBPropSet.PropertyId
Run Code Online (Sandbox Code Playgroud)
我猜这就是他们发明intellisense的原因......
关于多元化:在我看来,s
应该始终是小写的.
Dav*_*dRR 20
自从提出此问题以来,Microsoft已更新其指南.
在MSDN文章Capitalization Conventions(.NET Framework 4.5)中,有一个名为Capitalizing Compound Words和Common Terms的部分.在本节的表中,在命名标识符时,"identifier"的缩写给出了以下大小写指南:
System.Attribute.TypeId
)var id = 42;
)当ID是标识符等的缩写时,我总是将ID大写.它只是看起来不对,让我想起弗洛伊德,否则 - 这绝对不是一件好事.
归档时间: |
|
查看次数: |
8320 次 |
最近记录: |