Introduction to Computer Science II with Intensive C
Fall 1996

Programming Conventions
(Coding Guidelines)

This is a compulsory set of programming rules to foster the habit of following some convention consistently. These conventions are designed to improve code readability, on the premises that far more human time is spent reading code than writing it, that far more human time is spent modifying existing code than writing entire programs from scratch, that far more code is written by groups of people than by single individuals. In particular, following these rules will make it easier for the grader to grade your work and the instructors to assist you if you are having difficulty.

This convention is based on the implicit conventions used in our text books, especially The Art and Science of C by Eric Roberts. When there is a difference between what is done in the books and what is outlined here, this takes precedence. If you have a question about something not covered here, imitate the code from one of the texts.


As part of program documentation, names must clearly indicate both the kind of thing being named and its role in the program.

In addition to following the guidelines above to indicate what kind of thing you are naming, a name should be chosen which will reveal the meaning or use of that thing in your program.


Maintain consistent indentation throughout your code. Examples:
if (condition){
} else {

for (...){
For more examples, see the syntax boxes of chapter 4 in The Art and Science of C by Eric Roberts.

Rightward Drift. As you get more and more deeply nested block of code, indentation pushes you farther and farther to the right, until eventually you have hardly any room to write a line of code. To avoid this, you can do two things:


Comments should help the reader of your code to understand it. In the case of a programming course, they also serve to convince the grader that you grasp the what, how and why of your code (as opposed to having hacked it into working). Like any other form of expression, it should not be flowery or repetitive. In particular observe the following guidelines

Standard Boiler Plate

Each source file must have a standard "boiler plate". This boiler plate must include your name, the class (CS 113), the assignment number, due date, the problem number, and a brief description of the what the code in the file does. You should outline the method you used to solve the problem, describe the variables and data-structures used in the program, any error conditions which might be encountered in the solution, and how these error conditions are handled by the solution, any known deficiencies (documented bugs, cases which the program does not handle, etc.), and a separate list of enhancements (any features not required in the assignment) if there are any.

Specific Guidelines for the Boiler Plate: