4

If my class name contains any acronyms then how can i name?

Ex: SomeDAO or SomeDao

Also, if any variable has acronyms, how can i name?

Ex: private String appUID or private String appUid

Thanks!

user755806
  • 6,565
  • 27
  • 106
  • 153
  • 5
    I would go with the first example. There is no correct answer. personal choice. Though the first example is common one. – codeMan Nov 18 '13 at 11:09
  • 2
    Do not be scared to use longer names if they provide greater meaning, or resolve some confusion that might occur. e.g. drawingAppUid – Peter_James Nov 18 '13 at 11:10
  • if any abbrevation use first. othercase use second – subash Nov 18 '13 at 11:11

3 Answers3

3

From code convention for java provided by oracle :

Class names should be nouns, in mixed case with the first letter of each internal word capitalized. Try to keep your class names simple and descriptive. Use whole words-avoid acronyms and abbreviations (unless the abbreviation is much more widely used than the long form, such as URL or HTML

As DAO is widely used and accepted , i would go for SomeDAO

MD. Sahib Bin Mahboob
  • 20,246
  • 2
  • 23
  • 45
0

Quote from wiki:

Treatment of acronyms in identifiers (e.g. the "XML" and "HTTP" in XMLHttpRequest) varies. Some dictate that they be lowercased (e.g. XmlHttpRequest) to ease typing and readability, whereas others leave them uppercased (e.g. XMLHTTPRequest) for accuracy. A less popular option is to always expand any acronyms (e.g. ExtensibleMarkupLanguageHyperTextTransferProtocolRequest).

There is no ideal convention though but ideal approach should be to stick with whatever convention is choosen.

On a side not, following corner case could be considered: com.x.y.XMLHttpReq com.x.y.XMLHTTPReq

Assume that both of above were in different source folder and on-compilation bundled under one jar or bin folder: Windows (case in-sensitive) - may override or compiler error (depends if bulk compiled) *NIX (case sensitive) - fine

harsh
  • 7,502
  • 3
  • 31
  • 32
0

I would use applicationUniqueIdentyfier.