Search code examples
language-agnosticcoding-stylecamelcasingacronym

Acronyms in CamelCase


I have a doubt about CamelCase. Suppose you have this acronym: Unesco = United Nations Educational, Scientific and Cultural Organization.

You should write: unitedNationsEducationalScientificAndCulturalOrganization

But what if you need to write the acronym? Something like:

getUnescoProperties();

Is it right to write it this way? getUnescoProperties() OR getUNESCOProperties();


Solution

  • Some guidelines Microsoft has written about camelCase are:

    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. If you must use abbreviations, use camel case for abbreviations that consist of more than two characters, even if this contradicts the standard abbreviation of the word.

    Summing up:

    • When you use an abbreviation or acronym that is two characters long, put them all in caps;

    • When the acronym is longer than two chars, use a capital for the first character.

    So, in your specific case, getUnescoProperties() is correct.