Last modified: Sat Sep 11 15:08:01 HST 1999
| Guidelines |
| Example |
| private static float sumDiffSquares = 0; Counter | Example
| private static float Sum = 0; private static float sumdiffsquares = 0; private static float sum_diff_squares = 0; private static float x = 0; |
|---|
| Guidelines | Every class should be preceded with a descriptive comment using the "JavaDoc" notational convention. The comment should name the class, describe its purpose, and name the author and (optionally) the version using JavaDoc keywords. |
|---|---|
| Example |
/**
* Hello1 --- A simple program to print out "Hello World".
* @author Philip Johnson
* @version $Id: Hello1.java,v 1.3 1998/03/23 21:23:39 johnson Exp $
*/
public class Hello1 {
:
}
|
| Guidelines | Every method should be preceded with a descriptive comment using the "JavaDoc" notational convention. The comment should name the method, describe its purpose, comment all arguments, the return value, and any exceptions using JavaDoc keywords. |
|---|---|
| Example |
/**
* main --- Prints out "Hello World" and the command line arguments.
* @param arg A string array containing the command line arguments.
* @return No return value.
* @exception Exception If the file is not found or other error.
*/
public static void main (String[] arg) throws Exception {
:
}
|
| Guidelines | Every public variable should be preceded with a descriptive comment using the "JavaDoc" notational convention. The comment should describe the purpose for the public variable. |
|---|---|
| Example |
/** Toggles between Frame and NoFrame mode. */ public boolean FrameMode = True; |
| Guidelines | In-line comments should be used to explain complicated sections of code, such as loops. Use the // comment delimiter for in-line comments. Do not comment generally known features of the java language. |
|---|---|
| Example |
// Do a 3D transmogrification on the matrix in args.
for (int i=0; i < args.length; i++) {
for (int j=0; j < args.length; j++) {
for (int k=0; k < args.length; k++) {
vals.transmogrify(args[i], args[j], args[k]);
|
| Counter Example |
// the variable "i" loops from 0 to the length of args.
for (int i=0; i < args.length; i++) {
:
}
|
| Guidelines | Use two blank lines to separate each method within a class definition. Use one blank line to separate logical sections of code within a method. |
|---|---|
| Example |
public static void main(String[] arg) {
System.out.println ("Hello" + " " + "World");
}
public void foo() {
:
}
|
| Guidelines |
| Example |
|
public static void main(String[] arg) {
System.out.println("Hello" + " " + "World");
Counter | Example
|
public static void main(String[] arg){
System.out.println("Hello"+" "+"World");
|
|---|
| Guidelines |
| Example |
|
for (int i=0; i < args.length; i = i + 1) {
vals.insertElementAt(new Float (args[i]), i);
// Transmogrify is incremental and more efficient inside the loop.
vals.transmogrify();
}
Counter | Example
|
for (int i=0; i < args.length; i = i + 1)
{
vals.insertElementAt(new Float (args[i]), i);
// Transmogrify is incremental and more efficient inside the loop.
vals.transmogrify();
}
|
|---|
| Guidelines |
| Examples |
|
package foo.bar.baz;
public class MeanStandardDeviation
private Vector getNewVector(Vector oldVector) {
Counter | Example
|
package Foo.Bar.Baz;
public class Meanstandarddeviation
private Vector GetNewVector(Vector oldVector) {
|
|---|
| Guidelines |
|
|---|
| Guidelines | It is useful, but optional to include automated time/date stamping of creation and modification dates. Emacs and other decent editors will do this for free. |
|---|---|
| Example |
// -*- Mode: Jde -*- // meanStd.java -- // Author : Philip Johnson // Created On : Tue Dec 26 11:02:36 1995 // Last Modified By: Philip Johnson // Last Modified On: Thu Jan 4 16:02:01 1996 // RCS: $Id$ // // Copyright (C) 1995 Philip Johnson // // |