Java Coding Standard
Java Coding Standard
Java Coding Standard
Purpose
Program Headers
Header Format
/**********************************************************************************/
/* Program Name: the program name
*/
/* Author:
*/
/* Date:
*/
*/
/*********************************************************************************/
Listing Contents
Contents
/**********************************************************************************/
Example
/* Listing Contents:
/* Reuse instructions
/* Includes:
/* Import classes
/* Class declaration:
/*
Global variables declarations
/*
Main method
/*
Constructors //optional
/*
Class methods
*/
*/
*/
*/
*/
*/
*/
*/
*/
/**********************************************************************************/
Reuse Instructions
Describe how the program is used. Provide the declaration format, parameter
values and types, and parameter limits.
Provide warnings of illegal values, overflow conditions, or other conditions
that could potentially result in improper operation.
Reuse Example
/**********************************************************************************/
/*
Reuse instructions
*/
/*
*/
/*
*/
/*
*/
/**********************************************************************************/
Identifiers
Use descriptive names for all variables, function names, constants, and other
identifiers. Avoid abbreviations or single letter variables.
Identifier Example
(continued)
Comments
Document the code so that the reader can understand its operation.
Comments should explain both the purpose and behavior of the code.
Good Comment
Bad Comment
Major Sections
Example
/*******************************************************************/
/* The program section examines the contents of the
*/
*/
/*******************************************************************/
Blank Spaces
Indenting
Indenting
Example
int ivar1;
int ivar2;
Sample(int i, int j) {
ivar1 = i;
ivar2 = j;
}
int emptyMethod() {}
...
}
Capitalization
Capitalization
Example
Referencias
Carnegie Mellon University. (2006). Assignment Kit for Coding Standard. SEI.
Johnson, P. (1996). SourceFormatX. Recuperado el agosto de 2016, de Java Coding
Standard: http://www.sourceformat.com/coding-standard-java-johnson.htm