The standards below are not exhaustive: students are expected to follow sound software engineering practices and exercise good judgement and common sense throughout the development process - following poor processes or generating low quality code can still result in loss of marks even if it does not violate any specific guideline listed below.
git add .
",
Code that generates errors/warnings is not trustworth: no warning is too small to ignore.
stderr
output stream, not stdout
.
"Please enter the circle radius as a real number, e.g. 5.25"
"Enter value"
"Out of range value entered: 32 (should be an integer in range 1-19)"
"Bad value"
"For the circle of radius 5, the computed circumference was 31.4"
"Result 31.4"
circleRadius
is immediately clearer
and more meaningful to the reader than R
or cR
.
// variables to hold the three polynomial coefficients float a, b, c;
// prompt the user to enter the polynomial coeffients and // read them in, assume they are seperated by whitespace printf("Please enter the degree 2 coefficient,\n"); printf("followed by the degree 1, then the degree 0:\n"); scanf("%g\n", &a); scanf("%g\n", &b); scanf("%g\n", &c);
For example, userInitial would be a much more meaningful identifier than i, and fuelLevel would be a much more meaningful identifier than data.
For example, instead of the hard-coded value 3.1415 in the statement:
circumf = 3.1415 * radius;
we would introduce a named constant, e.g.
const float Pi = 3.1415; ....... circumf = Pi * radius;Similarly, if we have meanings associated with specific characters in the program they should be represented with constants.
For example, if we have the user enter Q to quit or C to continue, we might use:
const char QuitCmd = 'Q'; const char ContCmd = 'C'; ... printf("Enter %c to quit or %c to continue\n", QuitCmd, ContCmd);
The full implementation of the function should generally be accompanied by a more detailed set of (implementation specific) comments than the call-focused comments in the header file.
void myfunction(int someparameter) { ..... all this is indented 3 spaces ..... }
void doSomething(int arr[], int size) { int someLocalArr[size]; // size is NOT a constant ...(This won't apply to arrays that are dynamically-allocated using the "new", "malloc", or "calloc" operators, as discussed at the very bottom of this page.)
The debugging target should use the -g flag, while the "normal" target should disable asserts with the -DNDEBUG flag.
The .o files compiled for the debug versions should thus be stored separately from the .o files compiled for the "normal" versions.