Notes on Grading of Programming Assignments


How programs are graded


Special situations

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 not tested what you submitted even once.

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.


Normal situations

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. See below for scoring of errors.


Coding standards

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.



Extra credit

If your documentation is good throughout, where

  1. everything that needs documentating is documented,
  2. documentation follows all of the rules set out for it, and
  3. documentation is clear and easy to read

you will receive up to 10 points of extra credit.

You will only receive extra credit for documentation if your program is correct or mostly correct. You will not receive extra credit for a program that does not compile.

My decisions on extra credit are final. I will not justify why I did not consider extra credit to have been earned.


Reading the feedback

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 if you need one.

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 overlap or for the overall quality of the submission. But do not count on that.


Grading abbreviations and scoring

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-5 pts]

The modules are not correctly linked.

Do not #include a .cpp file in another file. Include header files instead. Link the compiled modules using a linker. (g++ will act as a linker for you.)

Incorrect linking is likely to be scored at the high end of the range.

Warnings [1-7 pts]

The standards require there to be no warnings. You will lose 2 pts for each serious warning (failure to return a value, using an uninitialized variable, for example) and 1 pt for each minor warning, up to a maximum of 7 points.

There is no reason that your program should have any warnings. Compile it with warnings turned on. If you do not see how to fix a warning, ask questions.


Following the assignment

Algorithm [1-100 pts]

The means an algorithm is incorrect. The points that you lose depends on how much of the program is represented by the faulty algorithm, and on how bad the mistake is. Each faulty algorithm is scored separately.

You would only lose 100 points in the most extreme situation where all functions are merely stubs. (A stub is a function that does nothing at all.)

Design [1-100 pts]

This means the program does not follow the required design. You are expected to follow the design. Completely ignoring the design can earn a score of 0.

File-name [1-2 pts]

Use file names indicated in the assignment. You will lose one point per file name up to a maximum of 2.

File name case[1 pt]

The case of file names matters. The Linux file system is case-sensitive. For example, hailstone.cpp and Hailstone.cpp are different file names. Use the correct name.

Functional requirements [1-100 pts]

This means the program does not do what it is supposed to do. The number of points lost will depend on how far off the result is, from a small issue that only costs 1 point to a program that does nothing remotely correct that can lose up to 100 points.

Organization [1-8 pts]

The program is not well organized. This can occur in situations where jobs are not broken up into functions in sensible ways, or where functions are not put in modules in sensible ways. Closely related functions should be close to each other wherever possible.

Long function [1-30 pts] A function should have no more than 15 noncomment lines.

Input source [1-5 pts]

The program does not read input from the correct source. That forces me to modify your program so that it will work in my tester. I do not test programs by hand.

Follow the instructions.

Output destination [1-5 pts]

The program does not write to the correct place. That forces me to modify the program so that it works in my tester.

Standard Template Library [1-50 pts]

The program uses the standard template library, which we are not using in this course. If you have used it, you have not followed the instructions. The points lost will reflect how much of the program you have worked around. If you use the STL to make the assignment trivial you will lose a lot of points.

Violate interface [10-20 pts]

This means that a module uses things from another module that should be private to that other module. Count on losing at least 10 points for doing that.

Always honor a module's interface.

Advertise private [1 pt]

A header file describes something that it should not describe because that thing should be private. This does not count things that need to be put into the header file even though they are really private.

Layout

Braces [1-4 pts]

Align matching braces in the same column without any characters in the vertical line segment between them (or to the left of that line segment).

You will lose 1 point for each set of misaligned braces.

Contract layout [1 pt]

Contracts are in the wrong place. Put a contract immediately before the function it describes.

Extra empty space [1 pt]

There are too many blank lines. Don't have more than 3 blank lines in a row. Don't double-space your program. Put blank lines in sensible places.

If-layout [1-2 pts]

Layout of if's with multiple cases is not correct. Use format
  if(condition-1)
  {
  }
  else if(condition-2)
  {
  }
  …
Each incorrectly aligned if will lose 1 point, up to a maximum of 2 points.

Indent [1-10 pts]

Indentation is not correct. You will lose 1 point for each occurrence, up to a maximum of 10 points. But see the the rule for extremely bad indentation, the next entry.

Indent-extreme [10-50 pts]

Indentation is extremely bad. I will take off a lot of points for that.

Warning. Email handlers are known to destroy indentation in the body of the email messages. Always send programs as attachments to avoid that.

Indent-sequence [1-10 pts]

This is counted as the same as Indent. It indicates that indentation is incorrect because two statements that are done one after the other should be indented the same amount, but they are not in the program.

Line pack [1-5 pts]

The program packs more than one statement on one line. You will lose 1 point per occurrence up to 5 points.

Long line [1-2 pts]

Avoid lines longer than 80 characters.

Statement component [1-5 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, { … }.

If you do not follow that standard, you will lose 1 point per occurrence up to a maximum of 5.

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 program 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.

Put a blank line before and after each type definition. (That does not mean two blank lines for two type definitions in a row. One blank line between them is good.)


Variables and parameters

Change CBV param [1-5 pts]

A function should not change the value of a call-by-value parameter. Use a new local variable instead.

You will lose 1 point for each occurrence up to a maximum of 5 points.

Default parameter [1-3 pts]

Do not use default parameters. (We will not discuss them.)

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]

This means a function has two variables that always have the same value when they are used (except to update themselves). That is unnecessary and confusing.

It can also mean that a local variable has been created that is just another name for a parameter.

Global variable [5-25 pts]

The program uses global variables, other than explicitly allowed, such as a variable that is used to control whether tracing is done, or a variable that controls whether the program does deletions. 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 v = value;
where v is a local variable. Don't do that. Just say
  return 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]

Do not use static variables.

Spurious-initialization [1 pt]

A variable is initialized with an unused value.

Uninitialized variable [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. You will lose one point per occurrence up to 5 points.

Type name [1-4 pts]

A type name is misleading or confusing. Choose a better name. You will lose one point per occurrence up to 4 points.

Variable name [1-4 pts]

A variable or parameter name is misleading or confusing. Choose a better name. You will lose one point per occurrence up to 4 points.

Booleans

Assign in test [1-3 pts]

You have used = in a test instead of ==. That can be a serious problem.

Boolean condition [1-2 pts]

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

Boolean eq [1-2 pts]

In a test, do not use condition == true or condition == false. Instead of condition == true, just use condition. Instead of condition == false, use !condition. For example, you should not write
  if(isprime(n) == true) 
  …

Boolean op [1-2 pts]

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

Contracts and documentation

Binary characters [3-6 pts]

Stick with 7-bit ascii characters in a C++ program. Don't use any weird characters.

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

This is a major headache for me. I usually have to restart everything, and it takes a lot of my time.

Comment [1-5 pts]

A comment is incorrect, incomplete, misleading or useless.

Contract [1-15 pts]

A contract or type description is not clear and precise. You will typically lose 1 point for a minor problem and 2 points for a more serious problem, up to a maximum of 15 points.

The terms listed below are equivalent to this. They just indicate some specifics.

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.

If you describe what another function uses f for or what another function passes to f, you are describing that other function, not f.

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 should refer to parameters by their names. Do not refer to a parameter as the number or it.

Contract parameters

A contract must say how the function's parameters affect what the function accomplishes. Explain how every parameter affects what the function accomplishes. Don't leave any out.

Contract requirements

A contract does not mention important requirements on a function's parameters.

Contract return

A contract must tell the significance of the returned value. Just telling its type does not tell its significance. What is it?

Contract side effects

A contract must document side-effects that the function has. (For example, if the function prints something, the contract must tell about that.)

Contract vague

A contract is vague or confusing.

Margin comments [1-3 pts]

Avoid putting comments in the margins except sparingly.

No contract

This means a function has no contract.

Top comment [1-2 pts]

If there is no comment near the top of the program telling what the function does when you run it, you will lose 2 points.

If there is such a comment but it is poor, you will lose 1 point.


Input and output

Eol at end of output [1 pt]

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

Getc type [1 pt]

Do not store the result of getc or getchar in a variable of type char.

Output format [1-5 pts]

Use the correct output format.

File open [1-3 pts]

If a file cannot be opened, the program must report that and give the name of the file.

File close [1-2 pts]

When the program is done with an open file, it should close the file.

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 function [1-5 pts]

This means a function does not do its entire job, or has bugs in it that other functions work around.

For example, if a function should not rely on its caller to do initialization or to complete a job that the function should do for itself.

Don't work around an incorrect function. Fix the function.

The points lost reflect how serious the problem is.

Duplicate function [1-5 pts]

Two functions do the same thing.

Extra parameter [1-3 pts]

This means there is an extra parameter that should not be there.

Typically, this means that there is a call-by-value parameter whose value is never used before the variable is changed. (You will also lose points for changing a call-by-value parameter if you do that.)

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. Typically, if this occurs, you will get a warning about it. Don't ignore the warning.

Return void [1 pts]

Do not use a return statement to return a void value. If you need to do a return in a function with a void return type, write
  return;

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]

This means that 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 expression as statement [1-4 pts]

Do not use form A ? B : C as a statement. You will lose 2 points per occurrence.

Constant condition [1-2 pts]

This means 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'. You will lose 1 point per occurrence up to a maximum of 2.

Empty then [1-2 pts]

This means 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. You will lose 1 point per occurrence.

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 changes control variable [1-3 pts]

This means the body of a for-loop changes the value of a variable that is controlled in for-loop heading. Don't do that. You will lose 1 point per occurrence.

For body changes 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.

For loop init [1-2 pts]

Use the first item in a for-loop heading for initialization.

Loop end [1-2 pt]

Code that is performed only in the last iteration of a loop should be moved to after the loop. You will lose 1 point per occurrence.

Loop with recursion [1-4 pts]

This means you have used both a loop and recursion where you should use either a loop or recursion. Do not write a recursive function that contains a loop.

Loop not loop [1-3 pts]

This usually means that you have used while where you should have written if. You have a loop that cannot do its body more than once. So there is no real repetition; the loop is a smoke screen.

Multiple loops [2-8 pts]

This means a function contains more than one loop. The standards require at most one loop per function. You will lose 2-3 points per occurrence.

Nested loop simulation [2-8 pts]

This means you have used one loop to simulate two or more nested loops by awkward ways of altering variables. Use two loops by writing another function that performs the inner loop.

You can recognize this if your loop has two control variables and it sets one back to some initial value when the other one reaches its end.


Statements and expressions

Bare semicolon [1-2 pt]

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

This can be a big problem when it is the body of an if-statement or loop.

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. You will lose 1 point per occurrence.

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.

You will lose 1 point per occurrence.

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 {}. You will lose one point per occurrence.

Pointers and memory management

Bad delete [2-8 pts]

The program deletes something that it should not delete (very serious), 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, Linux calls it a segmentation fault. Consider using a debugger to find the point where the memory fault occurs.

Memory leak [1-4 pts]

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

Reference count [1-7 pts]

Reference counts are not handled correctly.

Arrays

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.

This can be a very serious problem. It can corrupt the memory and make the program run amok.

Array size [1-2 pts]

If the size of an array is a constant, it should be a named constant.

Array too large [1-2 pts]

Don't be extravagant when creating arrays.

Reference array [1 pt]

An array is unnecessarily passed by reference.

General coding issues

Consistency [1-5 pts]

The program has inconsistencies.

Constructor [1-10 pts]

A constructor in a structure does not initialize all variables or initializes them incorrectly.

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.

You will lose 1 or 2 points per occurrence.

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]

This means 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 [1-2 pts]

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 or not done at all. The points lost will depend on how much tracing is missing.

The items below are special cases of this, and count toward the 10 point maximum.

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 of putting 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, not to a file with a fixed name.

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-10 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 so that you only need to compute it once.

The number of points per occurrence depend on the severity.

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-8 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.