1 Code formatting
2 Coding conventions
3 Code organization
4 Compiling the code
4.1 Method definitions
4.2 Data definitions
Version: 5.3.0.10

Java Style Guide for WebCAT submissions

1 Code formatting

2 Coding conventions

3 Code organization

4 Compiling the code

For the program to be graded it must compile. If you cannot complete any part of the assignment, you should comment out the parts that do not compile and submit it that way, subject to the following:

4.1 Method definitions

The assignment lists the methods that will be tested by the instructor’s test program.

If you cannot design these methods, include at least the method header and a stub code within that produces some value of the expected type. So, for example, if the method produces a boolean value, just write return true;, if it produces a String, wirte return "s";, etc. This will make your program compile and will run all instructor’s tests, even though they will probably fail.

4.2 Data definitions

Sometimes the assignment lists the specific instances of data that your program must define. Typically, these will be tested by the instructor’s test program.

If you cannot define the desired data, again, define any instances you can, as long as they are of the desired type. Try not to leave the data undefined.

Ordering the data definitions

Just like in DrRacket, if one of your pieces of data contains another instance of data, that item needs to be defined before it is referenced. Java will not signal an error for the code shown below:

 

Book catInTheHat = new Book("Cat in the Hat", drS, 20);

Author drS = new Author("Dr Suesse", 100);

but if you try to find out whether the author of catInTheHat is the same as drS it will fail. At the time the instance of the book catInTheHat has been defined, the author was unknown (null in Java), and the program does not go back to re-initialize all instances that have referred to drS when the field is finally initialized.

If you get unexpected "NullPointerException", check that all data definitions refer to object whose values are already known.

Note: If you can think of other helpful hints that should be included, please let me know and I will add them.