CSC134 Programming Standards
All programs must conform to certain basic standards. These standards are
designed to make programs readable, understandable, and easy to modify. The
programming standards we will follow include:
- Use meaningful variable names
- Named constants must be defined for all special constants used. Use const
rather than #define.
- Do not use global variables. Global constants are acceptable.
- Use functions to structure your program. Functions should be short, so use
lots of them. A general guideline is to make sure that no function is more than
one page long. Functions that are no more than a half page long are better.
Don't worry
about making functions too short or making too many of them!
- Use parameters only for variables that are shared between functions. If a
variable is only needed within one function, make it local to that function.
Comments must be used as follows:
- A comment section at the front of the program must include the
programmer's name, class, and section, the assignment number, the date, a
description of the program, and a comment on anything unusual or special that
the program does.
- Each function must be preceded by a comment section listing the name of the
function, a description of each parameter, and the purpose of the function
(a sentence or two should be enough description for most functions).
-
There should be enough comments to describe the purpose of all statements in
the program. A general guideline is to make sure that there are comments for at
least every 15 lines of code.
- Any tricky or obscure code should be explained in a comment.
Programs must be properly formatted.
- The program must use proper indentation.
- Each statement must be on a separate line. When a statement is continued
from one line to another, indent the continuation line(s).
- Blank lines or empty comments should be used to separate different sections
of the program (variable declarations, functions, etc.). Blank lines or empty
comments should also be placed before and after comments to separate them from
the program code.
Programs must have correct and nicely formatted output.
Program grades will be based on correctness of output, timeliness, and
the standards listed above.
Email Me |
Office Hours |
My Home Page |
Department Home |
MCC Home Page
© Copyright Emmi Schatz 2003