ITEC120-ibarland (incl. office hrs)—info—lectures—labs—hws
hw03 grading guide
Some common errors, marked with greek letters (lower-case).
(See also, common proofreading marks.)
- α (alpha):
Poor indentation.
The principle is simple:
if one line is a sub-part of another, then indent it.
For instance:
-
The body of a loop is indented relative to the first line of the loop.
-
The lines inside a method are a sub-part of that method.
-
Methods in a class are indented with
(Consider how reading this very paragraph is easier, because of how
the web browser indents items of a lists.)
Also,
- include blank lines between different methods
(since they are separate parts, like separate paragraphs).
-
Don't put blank lines between comments and the code being commented about.
-
Include spaces between words and punctuation, as needed.
For examples of good, readable code,
look at any code in the class notes or in the book.
- β (beta):
Lack of javadoc.
Include one @param for each parameter (explaining what it means),
and one @return if the method is non-void.
You should be able to look at the interface-view, and put yourself in
the mindset of a fellow programmer who wants to call your functions.
Do you provide enough information?
Note that your javadoc does not discuss
how your program works (its implementation),
but rather what your program does (its interface).
- γ (gamma):
Repeated code:
-
Kennel's oneYearPasses should
call each Dog's ageOneYear,
rather than repeating its code.
-
Kennels keep track of three Dogs only;
each Dog keeps track of its own name and age.
Thus: getAge occurs only in class Dog;
getDog1 occurse only in Kennel.
Do not have a Kennel method getDog1Age;
if your program needs that information it asks the kennel for dog1,
and then asks that dog for its age:
(k.getDog1()).getAge().
This was only 1pt off, as it was a widespread problem
(probably exacerbated by the way I had the Kennel
constructor be passed names and ages, rather than just
two Dog objects).
- δ (delta):
Magic number (or, magic string, or otherwise a magic literal).
- ε (epsilon):
Missing function: you didn't do something requested on the homework.
Please read the handout closely, else you'll lose easy points.
- ζ (zeta):
Incomplete test method.
You should have one or more tests for every method.
In particular, many people wrote discount,
but never called it from their test method
(which might have led people to think about the previous
item, of what should
happen to the price, after a discount).
- η (eta):
- θ (theta):
- λ (lambda):
Unclear/unhelpful comments.
An example of unhelpful commenting:
/** The lines of code below are taking in an ID and returning a boolean.
* @param id an ID.
* @return true or false
*/
static boolean isSoldByWeight( String id )
|
A more helpful description:
/** Returns whether or not the ID is for an item which is sold by weight.
* @param An ID `number', like "1572935" or "47AGM231".
* @return whether or not the ID is for an item which is sold by weight.
*/
static boolean isSoldByWeight( String id )
|
True, it is annoying to repeat the same info twice, but often (not always)
the @return line is also a succinct overall description.
(This is a lack of a single point of control, forcing me
to have the same information cut/pasted in two places.
Really, the program which generates a web page from your
program should use the @return line as the overall description,
if an overall description isn't otherwise provided.)
ITEC120-ibarland (incl. office hrs)—info—lectures—labs—hws