Java Programming Language Coding Conventions

4




Java Programming Language Coding Conventions

The following are the coding conventions of the Java programming language:

Packages – Package names should be nouns in lowercase. package shipping.objects

Classes – Class names should be nouns, in mixed case, with the first letter of each word capitalized.

class AccountBook

Interfaces – Interface names should be capitalized like class names.
interface Account

Methods – Method names should be verbs, in mixed case, with the first letter in lowercase. Within each method name, capital letters separate words. Limit the use of underscores.

balanceAccount()

Variables – All variables should be in mixed case with a lowercase first letter. Words are separated by capital letters. Limit the use of underscores, and avoid using the dollar sign ($) because this character has special meaning to inner classes.

currentCustomer

Variables should be meaningful and indicate to the casual reader the intent of their use. Avoid single character names except for temporary throwaway variables (for example, i, j, and k, used as loop control variables).

Constants – Primitive constants should be all uppercase with the words separated by underscores. Object constants can use mixed-case letters.

HEAD_COUNT

MAXIMUM_SIZE

Control structures – Use braces ({ }) around all statements, even single statements, when they are part of a control structure, such as an if-else or for statement.
if ( condition ) {
statement1;
} else {
statement2;
}

Spacing – Place only a single statement on any line, and use two-space or four-space indentations to make your code readable.

The number of spaces can vary depending on what code standards you use.

Comments – Use comments to explain code segments that are not obvious. Use the // comment delimiter for normal commenting; you can comment large sections of code using the /* . . . */
delimiters. Use the /** . . . */ documenting comment to provide input to javadoc for generating HTML documentation for the code.

// A comment that takes up only one line.
/* Comments that continue past one line and take up
space on multiple lines. */
/** A comment for documentation purposes.
* @see Another class for more information
*/




4 COMMENTS

  1. hello!,I like your writing very much! share we communicate more about your article on AOL? I need a specialist on this area to solve my problem. Maybe that’s you! Looking forward to see you.

  2. I think this is one of the most important info for me. And i’m glad reading your article. But should remark on some general things, The web site style is wonderful, the articles is really great : D. Good job, cheers

  3. whoah this weblog is magnificent i like studying your posts. Keep up the great paintings! You understand, a lot of individuals are hunting around for this info, you could help them greatly.

Comments are closed.