Programming Notes
These are some things I noticed in programs that I want to comment on so
you can tell what I am looking for in grading programs. Some of these are
style issues that are important, but there is no one right way to do them.
I'll try to be specific in the notes.
- Spacing and indentation
Spread the program out of the page. Leave spaces around parts
of statements. Leave space between sections of code. Think of paragraphs.
Several lines of code that work together to solve part of the problem are
a paragraph and should be set off from the rest of the code.
- Comments
Put long comments above the line, putting them after hides the code
when they wrap. Also, tell me what the statement is for, not what it does.
x=x+1; // increment x
is not helpful
x=x+1; // increment the vowel counter
is helpful, especially since x is not a good name for this. vowel_counter
would have been better.
-
Constants
I make my constants all capital letters so they stand out in the code.
That makes them more noticeable.
- Globals
Use globals sparingly, they make fixing a program harder since they
can be changed anywhere. I make the first letter in a globals name a capital
letter to make them stand out.
- Initialization
It is very important to initialize variables before you use them.