Every so often I hear a discussion start about whether ID should be used with both letters capitalized, or whether it should be Id.
The argument from the Id proponents is pretty simple. Id is short for identifier and when we use other acronyms, we normally just capitalize the first letter from each word.
I understand that argument and I see some merit in it. However, that's not the way I use it.
There are two reasons that I use it with both capitals.
The first, and I think the most important, is that "Id" is a complete word all by itself. The Cambridge dictionary defines it as:
in psychoanalysis, the deepest part of the unconscious mind that represents the most basic natural human needs and emotions such as hunger, anger, and the wish for pleasure
So a user can have an id quite separate to whether or not they have an ID.
The second, and also important for me, is that we read UserID as "user eye dee" and it's natural to capitalize the letters that we spell out in full.
For that same reason, I use OK and not Ok. I see OK as "oh kay", and Ok as "ock".
I know that no matter what I post, strong opinions with near religious conviction will be held on both sides, but I wanted to spell out my rationale.
Merriam-Webster seem to have the same rationale, and they classify the identifier as ID.
8 thoughts on “SQL: What's in a name -> UserId or UserID ?”
OK is actually an abbreviation for Old Kinderhook, so in that case "Ok" is definitely not OK, as an abbreviation for two words the only correct representation is all caps. ID is a different story, technically "Id" is more OK than ID which is technically incorrect and thus more like "Ok".
Having said all that I use ID in my code… it just stands out more than Id and you want IDs to pop as they're usually more important than the rest of your variables.
Yes, I've read a few etymologies for OK but agreed. What annoys me most is when I keep seeing alternating "OK" and "Ok" within a single product. (Azure DevOps I'm looking at you today)
My reason for using Id is that if it is part of a longer variable name that happens to have an acronym after it (UserIdHttpSession, for example) if you use uppercase for everything it becomes harder to read (UserIDHTTPSession). Therefore I never capitalise any word or acronym in full when it is part of a variable name.
Agreed. That's standard .NET naming conventions. It says to lowercase adjacent acronyms but that's not the typical use case for this.
I think UserID is the true one. But when you are programming in some languages like C#, then you should respect the Naming Conventions of that language.
So the UserID should be UserId in C#.
Agreed, but it's T-SQL here.
T-SQL defaults to case insensitive, right? So you should just go with uSEriD
We have Sponge Bob Case in our SDU Tools. Looks just like that !