Question

A short acronym is like ID or DB which has only 2 characters.

How to name these when pascal casing (for Property or Class names) and for Camel Casing (input prameters, arguments)?

I know each Company has their own standard but I'm looking for a more generally acceptable standard.

e.g. when pascal casing:

ProductID or ProductId?
IDOfProduct or IdOfProduct?
DBRate or DbRate?
RateOfDB or RateOfDb?

and when camel casing:

productID or productId?
idOfProduct?
dbRate?
rateOfDb or rateOfDB?
Was it helpful?

Solution

According to MSDN (or Msdn :)

  • Do capitalize both characters of two-character acronyms, except the first word of a camel-cased identifier.

  • Do capitalize only the first character of acronyms with three or more characters, except the first word of a camel-cased identifier.

  • Do not capitalize any of the characters of any acronyms, whatever their length, at the beginning of a camel-cased identifier.

More info here

OTHER TIPS

It doesn't matter.

This is really personal preference. When a short acronym finishes a name, I capitalize both:

testDB

or

TestDB

When a short acronym begins a name, I only capitilze the first because I think it makes it more readable:

dbTest

or

DbTest

It's all about readability. Whatever you choose to do, do it consistently.

Do capitalize both characters of two-character acronyms, except the first word of a camel-cased identifier.

A property named DBRate is an example of a short acronym (DB) used as the first word of a Pascal-cased identifier. A parameter named ioChannel is an example of a short acronym (IO) used as the first word of a camel-cased identifier.

Check this link.

http://msdn.microsoft.com/en-us/library/ms229043(v=vs.100).aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top