Pretty simple question: When i have a persistable object, it usually has a property called ID (for abstract classes).
So .. is the naming convention ID or Id?
eg.
public int ID { get; set; }
or
public int Id { get; set; }
cheers :)
PS. This is for .NET btw. FXCop conformat would be a bonus.
As others pointed out, Id is right according to .NET conventions, but somehow it doesn't feel right, so many people use ID (and still live).
I don't know what the content of your field will be (numbers, strings, guids), but if you want to skip the problem you may simply use another .NET convention for object identifiers: Name
Whatever you like it to be, just be consistent. ID is not a word, it's an abbreviation of identity. How to write abbreviations is something people argue about for a long time. E.g. is it
or
actually both can be found in use in different frameworks. Another popular abbr. with similar problem is UTF8.
It's just important to be consistent, because otherwise people always have to look up the correct capitalization for every method, if every method handles it in a different way.
I have my own convention for that. If the abbr. is at the end of the name, it is all capitalized, if it's somewhere else, it follows camel notation rules. E.g.
Why? I like abbr. to be capitalized. Most people expect URL or UTF to be capitalized. However, if in the middle of a name, it destroys the advantage of camel notation. The advantage of camel notation is that you see where a new word starts by capitalization. So compare:
In the first case, I don't see immediately the URL is one word and To is the next one. The T might be part of URL (URLT) and be a different abbr., thus I'll use the second form. If it's at the end however, it won't play a role, no other word follows, thus I prefer the capitalized form. I stick to this convention throughout all of my code.
I usually go with Identifier. If I really want to keep it short (as part of a longer identifier, for example), I use Id, unless it's a parameter or private member.
The .NET Framework Naming Guidelines say this:
"ID" is one of abbreviations hardcoded in FxCop naming rules that are always considered wrong spelled even if they are parts of other words. The only way I found to override it is adding "ID" to Acronyms as ():
It worked with FxCop 1.36. P.S. In general, I think that "Id" is a better alternative but sometimes it's impossible to change a name if it's generated based on XML files (or web services) which we don't control
We use ID internally, because Id seems to me like psychology speak, but FxCop complains, as ID is not an acronym, its an abbreviation (for Identity/Identifier). According to the FxCop rule, only acronyms that are two characters long are allowed to be all caps. Everything else should be Proper case.
We put a SuppressMessage attribute on the ID property, and everyone is happy.
http://en.wiktionary.org/wiki/id#Abbreviation
Why fight it?