DEDUCTION |
PROBLEM |
COMMENT |
-2 |
if( cond ) return true; else return false; |
Should be: return cond; |
-10 |
Insufficient Javadoc comments |
|
-6 |
Javadoc comments attempted, but in wrong place |
Prior to the method, rather than in the method |
-10 |
Complicated logic |
Each method should fit easily in 60 lines. |
-3 |
Consistently
inconsistent spacing. For instance, one loop looks like a[i ] = a[ i+1 ]; Another looks like a[ i]= a[ i + 1 ]; |
Pick one style and
stick with it. |
-10 |
Indenting disaster |
|
-5 |
Indenting problem |
|
-3 |
One time indenting problem that was really misleading to the reader |
|
-7 |
Horrible variable
names |
|
-3 |
Using o or l as a
variable name |
Avoid because they
look like 0 and 1. |
-2 |
Missing else, as in if( x < 0 ) { … } if( x >= 0 ) { … } |
Rewrite as if/else. |
-5 |
makeEmpty doubling inconsistency |
If you (exactly) doubled the array, then you could not have makeEmpty resize the array to length 0, without creating a bug. |
-8 |
toString is inefficient (or missing) |
|
-15 |
Messing up the default comparator completely. |
|
-5 |
Having the default comparator return 0 if one type is not Comparable. |
Should let the ClassCastException that is generated go through. |
-10 |
getItemsInInterval does not include pairs on the boundary |
|
-3 |
Gratuitious calls to create objects, as in Object temp = new
Object(); |
Should have been Object temp = null; |
-2 |
Nonsense code; for instance random calls that ignore return values. |
|
-25 |
Change made to public interface or test program |
|
-5 |
Declaring extra instance variables instead of local variables. |
|
-5 |
public/private decisions are poor |
|
-2 |
Using a while loop instead of an obvious for loop. |
|
-5 |
Making the nested class non-static |
|
-5 |
Having toString print the size, but not the items. |
|
-5 |
makeEmpty throws an exception if already empty. |
This is an unreasonable design decision. There is nothing usual about clearing a container that is already cleared. It is similar to initializing to 0 a variable that is already 0. |
-8 |
Two parameter constructor that accepts Comparator messed up. |
|
-2 |
Writing an else if, when an else was enough as in: if( x < 0 ) { … } else if( x >= 0 ) { … } |
Rewrite as if/else. |
-4 |
Wild-card import directives |
|
-3 |
Using System.arrayCopy when not needed, which often involved creation of a temporary array. |
|
-0 |
Using size==0 instead of calling isEmpty. |
|
-5 |
Abusive use of ++ operator, as in a[i]
= a[++i]; |
|
-1 |
Keeping capacity as a separate member |
Already stored as array length. |
-3 |
No space in toString to separate the items output, resulting in one giant string with no blanks. |
|
-5 |
Having isEmpty work by testing items[0]==null might not work, depending on implementation of deleteMin and deleteMax. If it didn’t work, points were deducted. |
|
-5 |
Catching ArrayIndexOutOfBoundsException to decide when it is time to expand the array. |
This is a big no-no. The test should be done explicitly, and exceptions should not be used as a substitute for if/else. |
-15 |
contains calls equals. |
|
-10 |
No disclaimer that work is your own |
|
-5 |
Disclaimer is not signed |
|
-5 |
Disclaimer does not include your name, typed into code |
|
-5 |
Submission not stapled or otherwise professionally bound |
|
-5 |
Floppy disk attached |
No floppies! |
-5 |
Submission in manilla envelopes |
No envelopes! |
-10 |
Zero-parameter constructor doesn’t work |
|
-2 |
Using if( ! (x || y || …. ) instead of more sensible && |
|
-3 |
Returning !contains() (because it calls contains twice, which is excessive) |
|
-5 |
Same anonymous class declaration in two places |
If you need it twice, it shouldn’t be anonymous |
-8 |
Using loop to implement isEmpty |
|
-15 |
Broken makeEmpty/add |
|
-40 |
Broken getItemsInInterval |
|
-10 |
add returns wrong value or doesn’t expand |
|
-10 |
Duplicate code |
|
-60 to -80 |
No output as required |
Program is assumed to not work (see above) |
F for course |
Cheating (plagiarism) |
|
F for course |
Cheating (falsified output) |
|