Search code examples
javanaming-conventionsuppercasecamelcasingabbreviation

Naming convention for upper case abbreviations


Should a method that returns an XML stream be called

public Stream getXmlStream();

or instead

public Stream getXMLStream();

What's your opinion about that? What's considered best practice?


Solution

  • There is no one correct answer. This wiki extract is helpful:

    Programming identifiers often need to contain acronyms and initialisms which are already in upper case, such as "old HTML file". By analogy with the title case rules, the natural camel case rendering would have the abbreviation all in upper case, namely "oldHTMLFile". However, this approach is problematic when two acronyms occur together (e.g., "parse DBM XML" would become "parseDBMXML") or when the standard mandates lower camel case but the name begins with an abbreviation (e.g. "SQL server" would become "sQLServer"). For this reason, some programmers prefer to treat abbreviations as if they were lower case words and write "oldHtmlFile", "parseDbmXml" or "sqlServer".