The following are requirements that apply to all programs.
Additional requirements will be given with a programming assignment.
Points may be deducted for requirements not fulfilled and for failure to follow good programming practices.
See lab policy.
Programs must run and compile with clang++
on the department's computers (e.g., WASP).
You must use the clang++
option -Wall
.
Do NOT commit any object or executable files. These can be generated.
Output must be readable and easy to understand
The contents of these folders will be copied over, by the grader, to the EVAL directory on the due date and used as your submission.
You have read only access to the EVAL folder.
If you wish to submit your assignment late you must contact the instructor/grader so they can copy your submission into EVAL.
See the lab page for more details about folder and file names.
A comment must be at the very top of each file with the following format. Substitute your name, the correct due date, and the correct program name as specified in the assignment.
/**
* Firstname Lastname
* program_name
* CS course_number
*/
There must be a comment at the top of each program, after the initial comment, describing what the program does.
The program body must include comments, see below.
The program must have the functionality described in the programming assignment.
There is no debugging output from your programs.
Your program does not have an infinite loop for any valid input.
The program must produce correct results with any valid input.
Just because a program compiles does not mean it is correct
Just because a program produces a correct result with 1 or 2 different inputs does not mean it is correct
Test your program thoroughly to insure that it performs correctly
Even thorough testing does not guarantee a correct program
All programs must compile and run on the CS Department's Computers.
All programs should follow good programming practices (see below).
The follow are fundamental good programming practices. All program you write should be written using the following guidelines.
Use good indentation.
Indentation is used so that blocks may be easily recognized. Two or four spaces per level is widely regarded as good.
Be consistent with indentation and indentation style.
Separate subtasks by empty lines.
To accomplish its task, a program or function often must perform a number of subtasks. Each subtask will require one or more C++ statements. This is analagous to sentences and paragraphs, a sentence is a C++ statement and a paragraph a subtask. Separate subtasks with empty lines so they stand out as units.
Include helpful comments.
Precede each subtask with a comment that describes what the subtask (code) does. Comments are included to describe the purpose of a statement or group of statements. it is not necessary to comment each line. Comment things that are unusual, non-standard, or complicated.
Define a variable right before its first use.
Initialize a variable when it is defined.
Initializations in C++ can be expressions that use previously defined variables, and can include function calls. An exception; don't initialize a variable if it will immediately receive input - any value you would use for initialization would not be meaningful.
Use good variable names.
This is very important.
A variable should have a name that is descriptive of the purpose of the value/object it stores.
Use constants.
If a variable's value will not change, make it const
.
If a method will not change anything within the class, make it const
.
Do not use line wrapping.
Ultimately, programs may be printed. If lines are too long, many printers simply put the end of the long line on the next line. This ruins the benefit indentation gives us. Avoid line wrap by keeping all lines less than 80 characters or so. Accomplish this by keeping editing windows 80 characters wide. Do not maximize editing windows.
You will learn more good programming practices as you progress.
It is a good habit to not change the value of input variables. They might be needed later on in the program with their original value. Use another variable instead.
It is a good habit to separate the input of values, calculations, and the output of values. This allows you to change the way that you prompt for input, or the way you perform the calculation, or the way that you output results without changing the other subtasks.
Pretend you are a user of your program and observe its output. Make it say what needs to be said neatly, clearly, and without and excess.
One of the best software development skills that you can learn is to start with a minimal program, get it to compile and run, and add to it in small, incremental steps with a new compile and run between each addition.