Andrew Stevenson's WebLog

Write Here Write Now

Syndication

.Net Languages

ADO.Net

Asp.Net (Misc.)

Asp.Net Controls

Bad Patterns

Err What?

Files and Folders

Forums

IE Add-Ins

Methods for the Madness

Performance

See Clearer, C#

Test Driven

ID vs. Id (The naming of things)

I have a longtime habit of naming things like UserID with the i and the d capitalized, but FxCop doesn't seem to like that and keeps recommending Id.

Which do you use and which do you think is correct?

 

Published Thursday, August 12, 2004 9:30 AM by AndrewSeven

Comments

# re: ID vs. Id (The naming of things)@ Thursday, August 12, 2004 9:50 AM

Here we use:
FooID (not FooId)
FooSql (not FooSQL)

I believe the published conventions agree camel-case for acronyms of three or more letters and caps for less. So the only possible issue would be if you don't consider ID an acronym *shrug*

-

# re: ID vs. Id (The naming of things)@ Thursday, August 12, 2004 9:54 AM

I have made it a habit of using CamelCase which would indicate that I should be using Id as opposed to ID. I usually reserve UPPERCASE for constants.

I apply the same standard when naming columns in my database entities as well. For example column name would be CustomerId and not CustomerID.

James Steele

# re: ID vs. Id (The naming of things)@ Thursday, August 12, 2004 10:08 AM

I do not consider Id an acronym but rather an abbreviation <sigh>. Thus the use of Id as opposed to ID. I would gather we could debate this as many before us have, with good arguments on both sides of the house.

James Steele

# re: ID vs. Id (The naming of things)@ Thursday, August 12, 2004 10:09 AM

I'm like you, I used to use ID, but fxCop has drilled the Id into me.

firefox

# re: ID vs. Id (The naming of things)@ Thursday, August 12, 2004 11:13 AM

I prefer "ID" as it is consistent with the way the framework names "ID" This also makes it consistant with the pronounciation... eye-dee as opposed to rhymes-with-squid.

Jim Bolla

# re: ID vs. Id (The naming of things)@ Thursday, August 12, 2004 11:29 AM

The confusion over "ID" and "Id" is from it's history: "ID" erroneously crept into our language (and many major dictionaries) due to most people pronouncing it "I","D" during WWII. Older dictionaries from the 40's and 50's usually have an entry for "I.D.", which the generation of lexicographers during the 70's and 80's didn't like. Thus, they removed the periods (since it's not an acronym) and it became "ID"...(which unfortunately conflicts with the abbreviation for "Idaho" and several acronyms like "Intelligence Department", "inner diameter", etc.).

Newer dictionaries have both "ID" and "Id", with a few noting that "Id" is syntactically preferred. (I picked up this tidbit during the late 70's when I worked for a company that phototypeset dictionaries for several of the largest dictionary publishers. I also picked up my penchant for being pedantic from a few lexicographers I knew back then...)

I cringe each time I see "ID" in identifiers of any sort...and go out of my way to change them. FxCop's rule is a good call.

Steve Hall

# re: ID vs. Id (The naming of things)@ Thursday, August 12, 2004 1:39 PM

I'm gonna have to vote ID as common usage in our language dictates. I have yet to visit a single bank, store or government building that had a sign stating "Photo Id required". Although it may be incorrect, every printed form of the word (used in the context of identification) that I have ever seen is spelled ID...not Id. But then again, we're programmers...we make our own rules :) In terms of naming fields/variables, I like the < 3 letters all caps, > 2 cammel case rule.

Mike Barger

# re: ID vs. Id (The naming of things)@ Thursday, August 12, 2004 3:44 PM

I agree with Jim and Mike here. ID has my vote. Eye-Dee. Not 'eyed'...

Wim Hollebrandse

# re: ID vs. Id (The naming of things)@ Thursday, August 12, 2004 3:55 PM

I just uncheck that stupid FxCop rule because it is NOT correct. It's ID people. If you look at the .NET Framework you will find IO, UI, ID all over. The rule is if it's a two-letter acronym/abbreviation then it's uppercase but if it's a word then it's not (e.g. AdRotator). Look at the Class Library documentation folks! Don't you want to be as close to the .NET Framework as possible?

So the bottom line is:
2-Letter Acronym/Abbreviation is UPPERCASE.
2-Letter word (e.g. Ad, Is, etc) is PascalCase.

(Note: the guidelines say PascalCase is for three or more characters but it should say for two letter words as well.)

Someone should really start bugging the MSDN Documentation and FxCop guys to fix this.

The snippet below proves the two-letter rule:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconabbreviations.asp

# When using acronyms, use Pascal case or camel case for acronyms more than two characters long. For example, use HtmlButton or htmlButton. However, you should capitalize acronyms that consist of only two characters, such as System.IO instead of System.Io.

# Do not use abbreviations in identifiers or parameter names. If you must use abbreviations, use camel case for abbreviations that consist of more than two characters, even if this contradicts the standard abbreviation of the word.

Nasseam Elkarra

# re: ID vs. Id (The naming of things)@ Thursday, August 12, 2004 9:17 PM

IO : Input Output
UI : User Interface
ID : Identification ...?

I have this feeling that ID was once an acronym for Identifying Document and thus should be ID.
This corresponds to signs in bars that say everyone must present ID and you don't just say your name.

Most common usage seems to follow this, but in code it usualy just means Identifier (or even Guid)

I think I'm gonna stick with ID, it will require a lot less explaining ;)

AndrewSeven

# re: ID vs. Id (The naming of things)@ Saturday, August 14, 2004 8:06 PM

I see all the arguments for a strict adherence to camel casing and cannot argue with the logic. I am retraining myself to use Id instead of ID. Still, I wish it were not so.

One of the biggest hurdles I faced learning C# after writing VB is its case sensitive nature. Writing code, or an email for that matter, I like to write out acronyms with capital letters. In VB I would write SQLConnection. I am now used to writing things out the way they should be. But as a matter of style I still like my old patterns better.

Michael Henderson

# re: ID vs. Id (The naming of things)@ Sunday, August 15, 2004 3:23 PM

We made a choice at the office that we should use camel case naming thus making "Id" the approriate choice although some will use the "ID" form still. I am a strong believer in "no exceptions" thus I find the Id form better.

Søren Lund

# re: ID vs. Id (The naming of things)@ Tuesday, August 17, 2004 7:44 AM

Here is commentary on the subject from the 'horses mouth':

http://blogs.msdn.com/brada/archive/2003/11/26/50848.aspx

Personally I'm converting myself over to use the FxCop way.

Darrel

# re: ID vs. Id (The naming of things)@ Wednesday, August 18, 2004 9:57 AM

I always use "Id" in C#/VB.NET/any other OO language. *But* I religiously use "ID" in database schemas.

Not looking forward to the religious battle I'm going to have with myself when SQL Server 2005 makes it to gold code...

JS Greenwood

# re: ID vs. Id (The naming of things)@ Wednesday, July 25, 2007 3:24 PM

Make sure you are consistent... and make sure you are obeying the laws.  Therefore, make sure you are always using Id.  The rules are there for a reason.  Don't let your personal emotions get in the way of doing what's right.

Jim Smith

# re: ID vs. Id (The naming of things)@ Thursday, October 25, 2007 10:47 AM

I vote for ID.  One reason is that the plural looks better.  Consider: "One ID, two IDs", versus "One Id, two Ids".  "Two Ids" looks like it should be written as "Two Id's", but then it gets confused with a possessive ("enforce the Id's uniqueness") or an is/has abbreviation ("my Id's changed recently").

Carl

# re: ID vs. Id (The naming of things)@ Wednesday, December 26, 2007 10:18 PM

Just came across this one. I should note that Id is also a psychological term coined by Freud. That being the case, ID seems a good way to differentiate the former. The previous poster mentioned "two Ids", which sound more like something that came out from a psychology book than from a program.

Esteban

# re: ID vs. Id (The naming of things)@ Thursday, January 17, 2008 4:47 AM

I think the mistake was that an abbreviation was chosen in the first place! Abbreviations are nasty.

They should have picked an acronym perhaps, like DI - Data Identifier.

Jake Collins

# re: ID vs. Id (The naming of things)@ Wednesday, February 13, 2008 5:27 AM

see MSDN

Capitalization Rules for Acronyms

msdn2.microsoft.com/.../ms229043.aspx

"NOTE:

The two abbreviations that can be used in identifiers are ID and OK. In Pascal-cased identifiers they should appear as Id, and Ok. If used as the first word in a camel-cased identifier, they should appear as id and ok, respectively."

serhio

# re: ID vs. Id (The naming of things)@ Wednesday, July 23, 2008 7:26 AM

It's simple - if you go according to CamelCase or pascalCase, then it follows that for the common rule is to start each new word with a Uppercase letter, thus identity document would become: ID, BUT, BUT, BUT, in our case the word in question is: identity or identifier, thus it can only become Id, because it's one word only.

werner

# re: ID vs. Id (The naming of things)@ Wednesday, January 28, 2009 4:56 AM

I'm going for ID.

First of all, it's the accepted norm in every day use. Secondly it is in accordance with the .NET naming conventions. Lastly a good number of people seem to be under the impression that ID actualy stands for Identification, and while this seems to be what most people think, it did originaly stand for Identification Data/Document. Hence it is, in fact, an acronym AND an abbreviation.

Chris

Leave a Comment

(required) 
(required) 
(optional)
(required)