Notes on Grading of Programming Assignments


How programs are graded

A program that does not compile or does not link correctly with itself receives a score of 0, no matter how small the error is that leads to that behavior. You are expected to test your work. If it does not compile or link, it is clear that you have never tested what you submitted.

A program that is extremely poorly indented will receive a failing grade, regardless of how well it works. I do not just run your program. I also read it. If it is very poorly indented, it is too difficult to read.

Assuming that a program compiles, links and is sufficiently well-indented, it will start with 100 points and lose points for things that it either does not implement at all or that are done incorrectly. The number of points that you lose will depend on the severity of the error and on how often it is repeated.

Each programming assignment is subject to the coding standards for this course. Be sure that you are aware of them. Scores will suffer for programs that fail to meet the standards.


You will receive feedback that uses the abbreviations shown below. Click on the abbreviation in the grade page. It will take you to this file. Click again to see a detailed description.

After the abbreviation is the name of the function that contains the error or issue, and (usually) the number of points lost, in parentheses.

In some cases, you will lose fewer points than the total of all of the individual parts, to account for the overlap or overall quality of the submission. But do not count on that.


Grading abbreviations

Those items that can lead to at least 5 lost points are shown in red.


Compilation and linkage

COMPILE-ERROR [100 pts]

There are compile errors.

LINK [1-6 pts]

The modules are not correctly linked. Do not include a .cpp file. Include the header file, and link the compiled modules.

WARNINGS [1-5 pts]

There are compile warnings. The standards require that there be none.

Following the assignment

ALGORITHM [1-20 pts]

An algorithm is incorrect.

DESIGN [1-100 pts]

The program does not follow the required design. The design is not optional or suggested.

EOL-AT-END-OF-OUTPUT [1 pt]

The last character written should be an end-of-line character.

FILE-NAME [1 pt]

Use file names indicated in the assignment.

FILE-NAME-CASE[1 pt]

The file name does not have the correct case of letters. The Linux file system is case-sensitive. For example, hailstone.cpp and Hailstone.cpp are different file names.

FUNCTIONAL-REQUIREMENTS [1-100 pts]

The program does not do what it is supposed to do.

ORGANIZATION [1-8 pts]

The program is not well organized.

LONG-FUNCTION [1-20 pts]

INPUT-SOURCE [1-5 pts]

The program does not read input from the correct source.

OUTPUT-DESTINATION [1-5 pts]

The program does not write to the correct place.

STANDARD-TEMPLATE-LIBRARY [1-15 pts]

The program uses the standard template library, which we are not using in this course.

VIOLATE-INTERFACE [10-25 pts]

A module uses things from another module that should be private to that other module.

ADVERTISE-PRIVATE [1 pt]

A header file describes something that it should not describe because that thing should be private.

Layout

BRACES [1-4 pts]

Braces are not placed in the same column.

CONTRACT-LAYOUT [1 pt]

Contracts are in the wrong place.

EXTRA-EMPTY-SPACE [1 pt]

There are too many blank lines.

IF-MULTIPLE-CASES [1 pt]

Layout of if's with multiple cases is not correct. Use format
  if(condition-1)
  {
  }
  else if(condition-2)
  {
  }
  …

INDENT [1-10 pts]

Indentation is not correct.

INDENT-EXTREME [50 pts]

Indentation is extremely bad.

INDENT-SEQUENCE [1-10 pts]

Two statements that are done one after the other should be indented the same amoung.

LAYOUT [1-5 pts]

The program has poor layout.

LINE-PACK [1 pt per occurrence]

The program packs more than one statement on one line.

LONG-LINE [1-2 pts]

Avoid lines longer than 80 characters.

STATEMENT-COMPONENT [1-7 pts]

A component of an if-, while-, do- or for-statement (or other construct with statements inside it) is required to be a compound statement, { … }

TABS [1 pt]

The program uses tabs but does not say how far apart the tab stops are.

TEMPLATE [1 pt]

You have not used the standard template for assignments. Use it.

USE-BLANK-LINES [1-2 pts]

Put a blank line between one function and the contract for the next function. Put a blank line between a function's contract and its heading.

Variables and parameters

CHANGE-CBV-PARAM [1-5 pts]

A function changes the value of a call-by-value parameter. Use a local variable instead.

DOUBLE-CHANGE [1-2 pts]

A simple statement changes the value of a variable more than once. The standards (and C++) forbid that.

DUP-VARIABLE [1-2 pts]

There are two variables that always have the same value. That is unnecessary and confusing.

GLOBAL-VARIABLE [5-25 pts]

The program uses global variables, other than for controlling tracing. The standards forbid that.

INVISIBLE-CHANGE [1 pt]

A function changes the value of a variable, but the new value is never used.

RETURN-VARIABLE [1 pt]

A function says return variable = value;.

SHADOW [1 pt]

One variable shadows another, or a variable shadows a function name. (That is, you have two variables in the same function that have the same name, or a variable that has the same name as a function.)

STATIC-VARIABLE [5-25 pts]

The program uses a static variable. The standards forbid that.

SPURIOUS-INITIALIZATION [1-3 pts]

A variable is initialized with an unused value.

UNINITIALIZED [1-5 pts]

The program uses a variable before storing any value into it.

Names of types, functions and variables

CONFUSING-NAME [1 pt]

Do not use 'o', 'O' or 'l' for a variable name.

FUNCTION-NAME [1-5 pts]

A function name is misleading or confusing. Choose a better name.

TYPE-NAME [1-4 pts]

A type name is misleading or confusing. Choose a better name.

VARIABLE-NAME [1-4 pts]

A variable name is misleading or confusing. Choose a better name.

Booleans

ASSIGN-IN-TEST [1-3 pts]

You have used = in a test instead of ==.

BOOLEAN-CONDITION [1-2 pts]

The condition in an if-, while-, do- or for-statement does not a boolean value (true or false). The standards forbid that.

BOOLEAN-EQ [1-2 pts]

Do not use condition == true or condition == false. Instead of condition == true, just use condition. Instead of condition == false, use !condition.

BOOLEAN-OP [1-2 pts]

The program uses || or && or ! on a non-boolean value. The standards forbid that.

Contracts and documentation

BINARY-CHARACTERS [2-5 pts]

You should never put non-ascii characters in a C++ program.

Non-ascii characters are those with numbers larger than 127. Terminals use them as special characters to change the behavior of the terminal. A non-ascii character can make it very difficult to edit a program because it changes the behavior of the editor.

This is a major headache for me.

COMMENT [1-5 pts]

A comment is incorrect, incomplete, misleading or useless.

CONTRACT [1-15 pts]

A contract is not clear and precise.

CONTRACT-CONTEXTUAL

A contract describes how the function is used elsewhere instead of what the function does. Describe what this function accomplishes in terms of its parameters.

CONTRACT-ENGLISH

A contract does not use correct English, spelling or punctuation.

CONTRACT-HOW

A contract tells how a function works, or tries to explain the function body. Tell what the function accomplishes.

CONTRACT-INCORRECT

A contract is incorrect; what it says is false.

CONTRACT-IRRELEVANT

A contract contains irrelevant information.

CONTRACT-PARAMETER-NAMES

A contract does not refer to parameters by their names. Do not refer to a parameter as the number or it.

CONTRACT-PARAMETERS

A contract does not say how the function's parameters affect what the function accomplishes. Explain how every parameter affects what the function accomplishes.

CONTRACT-REQUIREMENTS

A contract does not mention important requirements on its parameters.

CONTRACT-RETURN

A contract does not tell the significance of the returned value.

CONTRACT-SIDE-EFFECTS

A contract does not document side-effects that the function has. (For example, the function might print something, but the contract does not mention that.)

CONTRACT-VAGUE

A contract is vague or confusing.

MARGIN-COMMENTS [1-3 pts]

Avoid putting comments in the margins.

NO-CONTRACT

A function has no contract.

TOP-COMMENT [1-2 pts]

There is no comment near the top of the program telling what the function does when you run it. (That comment serves as a contract for main.)

Functions

COMPOUND-JOB [1-2 pts]

A function tries to do more than one basic job. It tries to do too much. Break it up into simpler jobs.

CRIPPLED [1-4 pts]

A function does not do its entire job, or has bugs in it that other functions work around. For example, it relies on its caller either for initialization or for completing the job in ways that the function should do for itself. Don't work around an incorrect function. Fix the function.

EXTRA-PARAM [1-3 pts]

There is an extra parameter that should not be there.

EXTRA-RETURN [1 pt]

There is a redundant return statement. Don't say to return at the end of a function with a void return-type. It automatically returns at its end.

NO-RETURN [1-5 pts]

A function with a non-void return type sometimes does not return a value.

RETURN-VOID [1 pts]

A return statement returns a void value.

TIE-TOGETHER [1-2 pts]

Do not embed code in a function that more sensibly should be written in a different function, and that function used where the code was embedded.

TRUST [1-3 pts]

One function calls another, but tries to work around a perceived bug in the function that is not really a bug at all. Let the function do its job.

Conditionals: If, switch, etc.

BOOLEAN-FORCE [1 pt]

You have done a test of a boolean expression where it would be better to use that boolean expression as a value without testing it. If you want a function to return a boolean value A, just say return A;.

BRANCH-SEPARATION [1 pt]

Code that is only performed when a function takes a particular branch of an if-statement should be written inside that branch, not after the if-statement.

CONDITIONAL-EXPR-AS-STATEMENT [1-2 pts]

Do not use form A ? B : C as a statement.

CONSTANT-CONDITION [1-2 pts]

An if-statement has a condition that is either always true or always false. Look more carefully at your program.

EMPTY-ELSE [1-2 pts]

If you want to do nothing when a condition is false, omit 'else'.

EMPTY-THEN [1-2 pts]

An if-statement does nothing when its condition is true. Rewrite the if-statement so that it does nothing when the condition is false, and omit the else part.

REDUNDANT-TEST [1-2 pts]

You are testing a condition again whose value is known. Don't test it.

SWITCH-FALLTHROUGH [1-3 pts]

You have not done a break or return at the end of a part of a switch statement.

Loops

FOR-BODY-CHANGE [1-3 pts]

The body of a for-loop changes the value of a variable that is controlled in for-loop heading.

FOR-BODY-END [1-3 pts]

Do not change the value at which a for-loop ends as a way to force the loop to exit. Use a break-statement for an early exit.

LOOP-END [1 pt]

Code that is performed only in the last iteration of a loop should be moved to after the loop.

LOOP-WITH-RECURSION [1-4 pts]

You have used both a loop and recursion where you should use either a loop or recursion.

MULTIPLE-LOOPS [2-8 pts]

A method contains more than one loop. The standards require at most one loop per method.

NESTED-LOOP-SIMULATION [2-8 pts]

You have use one loop to simulate two or more nested loops by awkward says of altering variables. Use two loops by writing another function that performs the inner loop.

Statements and expressions

BARE-SEMICOLON [1 pt]

You have used a bare semicolon as a do-nothing statement. The coding standards forbid that.

COMMA [1-3 pts]

You have used a comma as a sequencing operator in a way that makes no sense. (In C++, expression A,B computes A, ignores its result, computes B and yields the value of B.)

COMPLICATED-EXPRESSION [1-3 pts]

An expression is too long and complicated. Simplify it by computing parts and storing their values into variables.

CONSTANT-TYPE [1-2 pts]

You have used a constant of the wrong type. Typically, this means that you have used 48 to mean '0' or 0 to mean false, or something similar. Use the correct kind of constant. Never use a character code instead of the character.

INACCESSIBLE [1-2 pts]

There is code that cannot be reached. A function cannot do anything after it returns. Think again about what you want your function to do.

NO-EFFECT [1-3 pts]

A statement does nothing, but is not just {}.

Handling pointers

ARRAY-BOUND [1-20 pts]

The program uses an array index that does not exist in the array. Remember that the last index of an array of size n is n−1.

BAD-DELETE [2-8 pts]

The program deletes something that it should not delete, or uses delete A; for an array A (it should be delete [] A;) or uses delete [] p where p is not an array (it should be delete p;).

DANGLING-POINTER [1-8 pts]

The program makes use of a dangling pointer. That is a very serious problem.

MEMORY-FAULT [5-50 pts]

The program gets a memory fault when run. Most often, it is called a segmentation fault on Linux. Consider using a debugger.

MEMORY-LEAK [1-4 pts]

You program has a memory leak. It forgets to delete something that it should delete.

General coding issues

DUP-CODE [1-5 pts]

Some code has been unnecessarily duplicated. This can be because the two branches of an if-statement contain identical code or because code should be put into a function.

EOF [1-4 pts]

You have used feof without understanding what it does.

GOTO [1-15 pts]

The program contains a goto, which is not allowed by the coding standards.

INSTANCE-METHOD [1-6 pts]

The program uses object-oriented programming, which we are not doing in this course.

MAIN-RETURN [1 pt]

The main function does not return a value. The returned value is normally 0. Return 1 if your program encounters an error, such as inability to open a file.

SPECIAL-CASE [2 pt]

Do not include unnecessary special cases in algorithms.

TOO-COMPLICATED [1-5 pts]

Avoid unnecessary complication. Do not use a complicated algorithm where a simple algorithm is easier.

Do not use unnecessarily complicated coding of algorithms.


Tracing

TRACING [1-10 pts]

Tracing is not done correctly.

TRACE-BIG [1-2 pts]

A trace print is too long. Move the code into a function and call the function.

TRACE-COMMENT [1-2 pts]

You have commented-out a trace print. Instead, put an if-statement around it so that you can turn it on or off.

TRACE-CONTROL [1-5 pts]

You must be able to turn on or off every trace print.

TRACE-FILE [1 pt]

For this class, write traces to the standard output.

TRACE-INFO [1-4 pts]

A trace does not show information that it should show. Be sure to tell which function is doing the trace. Show the values of important variables.

TRACE-OMIT [1-6 pts]

The program has not done required tracing.

Efficiency

DUP-CALL [2-6 pts]

You do duplicate calls to a function where it is easy (or critical for efficiency) to avoid that. Put the result into a variable.

SCAN-FOR-SEARCH [1-3 pts]

You have used a scan algorithm for a problem that is better solved by a search algorithm.

EFFICIENCY [1-10 pts]

Do not use an outrageously inefficient algorithm where there is a simple efficient algorithm.

Other

AWKWARD

Code is awkward, difficult to understand.

OTHER

This is used for miscellaneous items.

PREPROCESSOR [1 pt]

You have used the C preprocessor incorrectly.