Correct Programming Style
Your first set of programs are very short and simple. However,
after that, your programs are going to be quite a bit more
complicated and harder to read. In the professional world,
your employer will want you to create code that is easy to
read and understand because others will probably need your
code to anaylze.
Well, you're not in the professional
world yet, but your TA does need to anaylze your code. And if
your TA can't read it because it is formatted poorly and
commented poorly, then your TA won't be happy. And when
the TA ain't happy (sing along), ain't nobody happy!
Some guidelines to keep your TA happy:
- Indent correctly. EMACS is a great help with this. Start at the
top of each function and press TAB then go down line by line,
just tabbing away. It's easy, painless, and its worth 5 points.
(5 points)
- Comment generously throughout and have meaningful variable names.
However, this does NOT mean comment
each line. Then it starts to look cluttered and your TA becomes unhappy.
In general have a comment for each loop, any group of mathematical statements,
and any time something weird is going on.
(10 points)
- Begin each function with a simple header, followed by a brief
description :
//---------------------------------------------------------------------
//
// function.main()
//
//---------------------------------------------------------------------
// This function really doesn't do anything
main()
{
// See? Nothing here
}
(5 points)
- Each file should have a banner as such (most important: name and section):
//---------------------------------------------------------------------
// Program "twoSquares.C" last revised on 10/12/96
//
// Name: John Doe
// Section: 28
// Purpose: To draw a simple figure on the screen.
// Input: Any printable character.
// Output: A figure consisting of two small squares, side by side.
// Method: The program prompts the user to enter a character, which
// it then uses in a sequence of simple output statements
//---------------------------------------------------------------------
(5 points)
Finally, you must use the script command outlined in
"How to Submit...". And print it out.
(5 points)
Commenting and style add up to a total of 30 points on each project grade.
John Escobar