Naming convention for upper case abbreviations

user321068 picture user321068 · Nov 26, 2011 · Viewed 11.1k times · Source

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?

Answer

codaddict picture codaddict · Nov 26, 2011

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".