Smalltalk balloon

Course Coding Standards


CS 2530
Intermediate Computing



Introduction

There are a few programming standards that we will follow in this course. I will try to follow them in all the code I give you, unless I mention that the code is a special case for demonstrating a specific point. I expect you to follow them in all the code you give me.



Programming

Feel free to ask for the rationale behind any standard. (I will explain many in class, but perhaps not all.)



Documentation

Document each file with a header block that includes at least:

Here's an example:

    //
    // FILE:     Ball.java
    // AUTHOR:   Eugene Wallingford 
    // DATE:     01/31/2012
    // COMMENT:  Factored out of Budd's Ball class state and paint behavior.
    //
    // MODIFIED: 03/08/2012 by Eugene Wallingford
    // CHANGE:   Added a getColor() accessor.
    //

Your block need not look exactly like this, but it should contain the same information.



Style

I do not require you to follow a lot of specific style rules, but I do ask you to follow several basic guidelines to improve the readability of your code.


  1. Indent your code to indicate that one expression is subsidiary to another. For example, say this:
        for (int i = 0; i < 10; i++)
            System.out.println( i );
    

    instead of this:

        for (int i = 0; i < 10; i++)
        System.out.println( i );
    


  2. Indent consistently. Indent all for statement bodies the same number of characters. Indent all if statement bodies the same number of characters. Be consistent within a single file and across multiple files. Adopt some conventions that you like, and stick with them.

  3. Use names that say what they name. For example, numScores is a better name than n, and numberOfScores is better yet. By convention, we use single-letter variable names in only one context: as (loop) index variables.

  4. Use uppercase characters to begin the names of classes. Use lowercase characters to begin the names of methods and instances. Use embedded uppercase characters in all names as a way combine mulitiple words in the same name, such as in numberOfScores.



Eugene Wallingford ..... wallingf@cs.uni.edu ..... September 10, 2012