2

Instead of explaning I'll provide a simple and short example:

I would call a class that parses XMLs XMLParser. Sometime I run into problems, e.g. I want to create a class that labels XMLs, but XMLLabeler seems kind of odd, because of the two same letters.

Since XML is a wide spread term it should be no problem to resolve this 'issue', but for more complex acronyms this leaves a bad taste.

How would you handle these kind of things? Stricty applying camel case? I. e. XmlParser, XmlLabeler? Are there any naming conventions for acronyms in class names?

mike
  • 4,929
  • 4
  • 40
  • 80
  • As per JLS 6.2 http://docs.oracle.com/javase/specs/jls/se7/html/jls-6.html#jls-6.2 I'm apparently referring to identifiers and not names... – mike Aug 21 '13 at 15:08

1 Answers1

6

Camel Case (XmlParser) is the preferred way because it is easier to read

dkatzel
  • 31,188
  • 3
  • 63
  • 67
  • Could you back that up please? – mike Aug 21 '13 at 14:58
  • 2
    Effective Java (1st ed) p.165- 166: "While uppercase is more common, a strong argument can be made in favor of capitalizing only the first letter. Even if multiple acronyms occur back-to-back, you can still tell where one word starts and the next word ends. Which class name would you rather see, HTTPURL or HttpUrl ?" – dkatzel Aug 21 '13 at 15:08