I often see Java class names like
XmlReader
instead of
XMLReader
My gut feeling is to completely upper case acronyms, but apparently many people think differently. Or maybe it's just because a lot of code generators are having trouble with acronyms...
So i would like to hear the the public opinion. How do you capitalize your class names containing acronyms?
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.
Meaning of camel case in English. the use of a capital letter to begin the second word in a compound name or phrase, when it is not separated from the first word by a space: Examples of camel case include "iPod" and "GaGa".
When multiple words are used to form a variable, camel case joins those words together, without any white space, and delineates the start of each new word with a capital letter. In contrast, snake case uses an underscore between words to create separation.
CamelCase Defined Camel Case (stylized as CamelCase), is a convention of writing phrases or compound words in such a way that they form a single word. The first letter of each of the words is capitalized so that each of the words that would make up the constructed term could be read easily.
We use the camel case convention like Java and .NET do. Not for reasons of code generators, but for readability. Consider the case of combining two acronyms in one name, for example a class that converts XML into HTML.
XMLHTMLConverter
or
XmlHtmlConverter
Which one do you prefer?
Two reasons:
XmlHtmlConverter
. Now XML and HTML aren't such good examples, because everyone knows what XML is, and what HTML is. But sometimes you'll see less obvious acronyms and then this becomes important.XmlHtmlConverter
, you can type in XHC
in the Open Type dialog and it will find it. For an XMLHTMLConverter
, the initials would be XMLHTMLC
which is of course a bit longer.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With