Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Camel casing acronyms?

Tags:

java

c#

This question may seem pedantic or just silly, but what is your practice for camel casing when it comes to acronyms? Do you insist that everything, even acronyms must be camel cased, or do you make an exception for acronyms. Explanations would be great too. I'm not sure how this practice effects IDE features (autocomplete) or what the industry standard are.

like image 948
stevebot Avatar asked Dec 21 '10 22:12

stevebot


People also ask

Should acronyms be capitalized in CamelCase?

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.

What are camel case letters?

What is CamelCase? CamelCase is a way to separate the words in a phrase by making the first letter of each word capitalized and not using spaces. It is commonly used in web URLs, programming and computer naming conventions. It is named after camels because the capital letters resemble the humps on a camel's back.

What is Pascal and camel casing?

Camel case and Pascal case are similar. Both demand variables made from compound words and have the first letter of each appended word written with an uppercase letter. The difference is that Pascal case requires the first letter to be uppercase as well, while camel case does not.

Why is it called Pascal case?

Pascal case naming convention The use of a single uppercase letter for each additional word makes it easier to read code and discern the purpose of variables. The term Pascal case was popularized by the Pascal programming language. Pascal itself is case insensitive, so the use of PascalCase was not a requirement.


2 Answers

For C#, check out Microsoft's guidelines:

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.

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

A class named XmlWriter is an example of a long acronym used as the first word of a Pascal-cased identifier. A parameter named htmlReader is an example of a long acronym used as 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.

A parameter named xmlStream is an example of a long acronym (xml) used as the first word of a camel-cased identifier. A parameter named dbServerName is an example of a short acronym (db) used as the first word of a camel-cased identifier.

like image 151
Andrew Hare Avatar answered Sep 23 '22 04:09

Andrew Hare


Personal preference.

I tend to do it just because it doesn't merge well with other words, like, XMLHTTPParser, compared to XmlHttpParser. Do whatever makes you feel good, but do it in a standard way.

like image 32
Noon Silk Avatar answered Sep 24 '22 04:09

Noon Silk