ID or Id? Naming conventions in code

This topic is not as toxic than the tabs-vs-spaces or 2 vs 4 indents discussion, but it’s still something every coder I have met have an opinion about, no matter the programming language:

Which is correct:

  • OrderId
  • OrderID

Lets solve this ancient mystery like any programming problem is solved: We Google it.

THE MERRIAM-WEBSTER DICTIONARY

According to Merriam-Webster, ID is short for identification, spelled with 2 capital letters. This matches the intention of OrderID as “Order identification“.

ID wins

WIKIPEDIA

In Wikipedia we can learn that Id is part of the Freudian psyche structural model, and is used to describe the Id, ego and super-ego. When searching for id however, the 2 capital letters “ID” leads to an article on Identity Document and Identifier, the intended description of the ID in OrderID.

ID wins

MICROSOFT .NET CAPITALIZATION CONVENTIONS

Microsoft does not agree with Merriam-Webster, and clearly states that Id should be written with one capital letter, as OrderId.

Id wins

COLLINS DICTIONARY

The Collins dictionary also states that ID is a noun and means identity or identification, while Id is short for Idaho.

ID wins

CAMEL CASING

You would think that camel casing would vote for Id, but no, when you have two letters, both should be upper case. When you have three, only the first one should be upper case.

ID wins

GOOGLE DEVELOPER DOCUMENTATION STYLE GUIDE

Google is on the ID team, unless its in string literals and enums:

Not Id or id, except in string literals or enums. In some contexts, best to spell out as identifier or identification.

ID wins, but since Id is allowed in some contexts, I will say this is a draw.

CONCLUSION

Well, ID is the winner over Id with a 5-2 victory. This does not make you a bad programmer should you choose to use Id instead of ID. As long as you do it consistently. And if in doubt, you could always waste a few more bytes and spell out the entire ID:

  • OrderIdentity

But tell me what do you think? OrderID or OrderId?

OrderID or OrderId

To orderID or orderId, that’s the question 

MORE TO READ:

About briancaos

Developer at Pentia A/S since 2003. Have developed Web Applications using Sitecore Since Sitecore 4.1.
This entry was posted in General .NET and tagged , , . Bookmark the permalink.

1 Response to ID or Id? Naming conventions in code

  1. John Burke-Hansen says:

    Nice post, biG faN of the rIGht capitaliZation

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.