Computer Science

Course Coding Standards


Course Coding Standards
  1. Compilation and Execution
    1. Your programs should compile with no warnings or errors. If it does not compile, the program will receive no credit. And I will not spend long looking for the problem.
    2. Code should  run with no warnings or error messages unless testing error conditions.
  2. Documentation
    1. Name your files as instructed in the assignment, if applicable. You can choose your own names otherwise.
    2. At the top of all submitted files, include comments which specify
          Programmer, Date, Homework or Laboratory assignment to which it pertains.
    3. NOTE: the homework or laboratory number given should match the one used for that particular assignment on the course web pages rather than any private system of your own.
    4. If you worked on any code with someone else, either giving or receiving help, you should note that interaction above the relevant code. You should include the name(s) of the person(s) you worked with and what exactly you were consulting on. Failure to do so, will be interpreted very negatively.

      Any submitted code should be fully understood by all parties. Failure to do so will, again, be interpreted very negatively.

    5. For citation, all submitted files, regardless of size, will at the top include a brief description of "big picture" workings of your code.
      Write this to yourself as if you were to pick up the program six months from now and wanted to quickly reacquaint yourself with what it does. You want an overview with only enough detail to explain what the program is expected to do.

      Example:

                       """------------------------------------------------------------------ 
      
      
      Casey Jones September 8, 2044 Homework #1: Problem 1
      Command line arguments are two integers. Program makes sure both are positive and prints an informative result about whether or not either evenly divides the other. Collaboration: Hunter Smith helped me out on checking for positive numbers. Showed me how to correctly use variable & convert from args[0]. I helped Pat Guntz & Mars Zu with division versus modulus. They were confused about about how to call from math. ------------------------------------------------------------------ """
  3. Formatting & Indentation
    1. Never use any column beyond 80.
      Why? Code which "wraps" is harder to read & understand when viewing (or printing!). Your poor instructor will be doing this A LOT. Column 80 is safe for all reasonably readable font sizes.
    2. Do not use tabs.
    3. For each "inner" scope, indentation should be exactly 4 spaces.
    4. In-line comments must begin in same column and above code they describe.
    5. Off-to-side comments must all begin in same column throughout source file.
    6. Always leave at least one space between comment delimiter and the comment itself.
    7. Make good use of 'white space'.
     
  4. Delete unused code.
  5. Variables, Names, & Identifiers
    1. Variable names, module names, and any function/method names begin with lowercase letters. Those that read as multiple words are run together, with each successive word capitalized. Examples are circleRadius and upperLeftCorner.
      Alternatively, parts of names can be separated with the underscore _ character. Pick one style and use it consistently.
    2. Class identifiers begin with uppercase letters. Class names that read as multiple words are run together, with each successive word capitalized. Examples are DinosaurClient and StatsClient. No class should be named with the word 'class' as part of it's name.
    3. All variables, method, and function names and identifiers should be carefully named and as meaningful as possible.