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 no convention regarding "ID"; "ID", "Id" and even "iD" are used inconsistently.
****Question**: In .NET, how do you guys capitalize "ID"? For an example, nodeID, nodeId? FolderID or FolderId?
****Edit**: How about plural cases? then should I do "NodeIDs" or "NodeIds"?
Thanks
Capitalization is for 2 letters acronyms. UI, IP, etc.
"Id" is an abbreviation for Identifier, so it should stay pascal cased.
I think that the reason some people are using 'ID' instead of 'Id' is because it is a subset of 'GUID', 'UUID' or 'UID' that are generally capitalized.
I agree that it should be 'Id' but I think that it strongly depends on the context because in some environments it might be more appropriate to use 'ID'.
So to me 'ID' is a technical term and a subset of the above or used to refer either one of these technical terms whereas 'Id' is the shorthand to any kind of identifier and in a non-technical context when you need a person to read it like in your public APIs or UML you should (in my opinion) use 'Id'.
Microsoft has updated its guidelines since this question was asked.
In the MSDN article Capitalization Conventions (.NET Framework 4.5), there is a section named Capitalizing Compound Words and Common Terms. Within the table in this section, the following capitalization guidelines are given for the abbreviation for "identifier" when naming identifiers:
System.Attribute.TypeId
)var id = 42;
)The latest guidance is "Id", for more on this and others (e.g. "Ok"), see my post on the very latest Framework Design Guidelines (2nd edition)
If you would care to check the dictionary, you would find that ID is not treated as an abbreviation. In fact, the form is specified as ID or I.D. there. This is probably because it came from an expression like "Identity Documentation" or "Identification Data", and was not originally taken as a short form of "Identifier". Thus the form ID is not only recommended, but is directly supported by the dictionary.
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:
(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.