.NET naming convention for “ID” (anything identification: Capitalization)

前端 未结 7 792
情歌与酒
情歌与酒 2021-01-31 08:52

I am in the process of unifying these inconsistent naming conventions and this one problem has been a bit driving me crazy lately.

In the code base I am working with has

相关标签:
7条回答
  • 2021-01-31 09:26

    Microsoft's naming guidelines suggest using all capitalized for 2 letter acronyms made into identifiers (IP, IO, UI, etc), so I tend towards "ID" (even though it's not an acronym) because when I read it, I still say the letters individually.

    But honestly, I don't think Microsoft knows/knew what to do with ID/Id either:

    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
    

    (from http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/dcb8e08b-026a-4903-a413-7dbdda131a82/)

    I guess that's why they invented intellisense...

    In regards to pluralization: in my mind the s should always be lower-case.

    0 讨论(0)
提交回复
热议问题