Java Programming Conventions for Data Structures and Algorithms

This document describes the programming conventions to be used for Java code in the CITS2200 Data Structures and Algorithms unit. Students are required to follow these conventions in order to obtain full marks for their practical work.

Nomenclature

The conventions for identifier names are as follows:

In all cases except constants, upper case letters are used within identifiers to separate "English" words and make the identifiers more readable. Examples include QueueBlock and isEmpty. For constants, underscores are used.

These conventions are designed to follow as closely as possible to those used by the creators of Java. For example, in the statement:

System.out.println ("hello");

System is a class, out is an instance variable, and println is a method.

Similarly, in:

Character.isSpace(' ');

Character is a class and isSpace a method.

File names should be the same as the (principal) class stored in the file and package names should match the directory structure in which the file is located. This is required by the Java packaging methodology. For example, Java will look for the class DAT.QueueBlock (where DAT is the package name) in the file: ./DAT/QueueBlock.java

The CITS2200 unit will cover a number of different implementations for each abstract data type. For example, we will consider at least three different representations for a queue: block, block with (cyclic) wraparound, and a linked version. To distinguish between the different implementations, the convention is to name the implementation after the abstract data type, appending after this name an indication of the representation. For example:

QueueBlock QueueBlockCyclic QueueLinked

would be appropriate for the three mentioned implementations of the Queue interface. This convention has the added advantage that all implementations of the same ADT will be listed together in indexes and directory listings.

We will regard clarity as more important than brevity and hence sometimes use quite long filenames. This should not cause unnecessary inconvenience providing you are familiar with ideas such as cutting and pasting, filename completion, and navigation through command histories.

Formatting

Java code should be formatted according to the following conventions.

Commenting Programs

Programs submitted for this unit must be fully documented using the javadoc Java automatic documentation facility. In particular, all classes and their fields (both class and instance variables) and methods should be preceded by javadoc comments.

Documentation for methods should include:

Note that javadoc comments may not be sufficient on their own, and you should include additional comments to improve the ease with which your code can be understood and modified by others. Additional documentation requirements for a particular project will be included in the project description.