Friday, October 12, 2007

Java Faqs - What are the naming conventions in Java?

The naming conventions are straightforward:
1 . Package names are guaranteed uniqueness by using the Internet domain name in reverse order: com.javasoft.jag - the "com" or "edu" (etc.) part used to be in upper case, but now lower case is the recommendation.2 . Class and interface names are descriptive nouns, with the first letter of each word capitalized: PolarCoords. Interfaces are often called "something-able", e.g. "Observable", "Runnable", "Sortable".3 . Object and data (field) names are nouns/noun phrases, with the first letter lowercase, and the first letter of subsequent words capitalized: currentLimit.4 . Method names are verbs/verb phrases, with the first letter lowercase, and the first letter of subsequent words capitalized: calculateCurrentLimit.5 . Constant (final) names are in caps: UPPER_LIMIT. Other sites:6 . Check out the section "Naming Conventions" in the language specification: 7. Also take a look at Doug Lea's draft coding standards:

No comments: