This Style Guide should be used as a reference for all work turned in for credit, both labs and programming assignments. It is based on (but not identical to) standard java coding guidelines.
All names should be descriptive and readable:
subTotal
rather than s
;
grade
rather than grd
. Multiple
word names should use a capital letter to separate words
(e.g. subTotal
). Code should be
self-documenting.
subTotal
studentName
or subTotal
)printLine
or addColumn
)HelloWorld
).
PI
, INTEREST_RATE
).Where and when to declare variables.
for
loop may be declared within
the body of the loop (inside of the for
loop
header).Indentation provides a visual structure for your program.
sum = myGrade + yourGrade;
myGrade++;
System.out.println();
pay = (hours * 1.5) + bonus;
Structure provides readability.
Comments provide a guide to what the program is doing.
/** */
)
describe each class and
method. Such comments must include the appropriate tags:
@author, @version, @param, @return,and @exception
Every class file must contain a description formatted like the following.
/********************************************************************** * Overall description of the class goes here * @author Your name goes here * @version Vn -date (date may be in MM/DD/YY or MM/YY format) **********************************************************************/
Every programming assignment must contain the following section which follows the class description or must cite any sources used (such as a TA). You should either include this statement in all files or minimally it may appear in the file containing your main method.
/********************************************************************** * References and Acknowledgements: I received no outside help with this * programming assignment. ***********************************************************************/
/********************************************************************** * References and Acknowledgements: TA Glenn helped me with the * foo method. ***********************************************************************/This acknowledgement is not necessary for lab assignments.
All methods must contain a javadoc comment preceding the
method header as shown in the example below. The
description should describe the "black box" behavior of the
method (what it does). If there are parameters, then
there must be one @param
tag for each parameter
in the format shown below. If there is a return value,
there must be one @return
tag which describes the
return value (not the variable name). Finally, if the
method throws one or more exceptions, @throws
tags must be used to describe the circumstances under which
each exception will be thrown.
/********************************************************************** * Overall description (black box behavior) of the method goes here * @param parameterName Describe each input parameter. You must have one * @param line for each parameter * @return Describe the value that this method returns. * @throws ExceptionName Describe under what conditions the exception may * be thrown ***********************************************************************/NOTE: In the main class (the class that contains the main method) your method description may reiterate the class description but should contain a detailed description of any arguments being passed into the application via the command line arguments.
Math.PI
rather than 3.14159
)else
if it is not needed.break
and continue
statements within a loop, but you may lose points if they are
used incorrectly or where there is a better solution to ending
the loop. HINT: Don't use break or continue except for switch
statements.private
unless there is a documented reason for
not doing so.public
if they
are provided as a service to outside classes (such as Math.PI
).