Please send questions to st10@humboldt.edu .

CS 132 Style Guidelines
(a work in progress)

CS 132
Introduction to Computer Science II
Spring 2003


Last modified: Thu Mar 6 16:07:47 PST 2003
  1. Do not write expressions that require intimate knowledge of Java's rules of operator precedence to be able to read correctly --- use parentheses to make the meaning of arithmetic expressions obvious.

  2. In general, you are expected to use named constants instead of literal values in your code.
  3. Every function (and many methods) are expected to be preceded by at least a PURPOSE STATEMENT using the following format:
    /* Purpose: write purpose of function/method here, using parameter names
                as appropriate for clarity
     --------------------------------------------------------------------------*/
    
  4. Each function/non-constructor or non-simple-accessor method that you write is expected to have a corresponding testing function/method, whose name is the name of the function/method followed by Test and which uses the functions testHeader(), expected(), and actual() as discussed in class and in the readings to test that function appropriately.

    For a function, the test function should follow the function; for a method that is part of a class, the corresponding test method can go in the test class for that class.

    This testing function/method should be preceded by at least:
    /*  Examples/Tests:
     ----------------------------------------------------------------------*/
    
    ...or...
    /*-----------------------------------------------------------------------
     Test method for methodName()
     -----------------------------------------------------------------------*/
    
    ...although you may add to this if you wish.

  5. (from TeachJava readings) "Redefine (override) the toString() method for every class that is used to represent data."

  6. Java case/capitalization guidelines (quoted from TeachJava readings, section 1.3.8)
  7. Thou shalt name new exception classes so that their names end with "Exception" --- that is, MyNewException, CustomizedSpecialException, etc.