Data - TheRedLady/nemetschek_internship GitHub Wiki

General Considerations In Using Data

Initializing Variables

  • Does each routine check input parameters for validity?
  • Does the code declare variables close to where they're first used?
  • Are counters and accumulators initialized properly and, if necessary, reinitialized each time they are used?
  • Are variables reinitialized properly in code that's executed repeatedly?

Other General Issues in Using Data

  • Do all variables have the smallest scope possible?
  • Are references to variables as close together as possible, both from each reference to a variable to the next reference and in total live time?
  • Are all the declared variables being used?
  • Does each variable have one and only one purpose?
  • Is each variable's meaning explicit, with no hidden meanings?

Numbers in General

  • Does the code avoid magic numbers?
  • Does the code anticipate divide-by-zero errors?
  • If variables with two different types are used in the same expression, will the expression be evaluated as you intend it to be?
  • Does the code avoid mixed-type comparisons?

Integers

  • Do expressions that use integer division work the way they're meant to?

Floating-Point Numbers

  • Does the code avoid additions and subtractions on numbers with greatly different magnitudes?
  • Does the code systematically prevent rounding errors?
  • Does the code avoid comparing floating-point numbers for equality?

Characters and Strings

  • Does the code avoid magic characters and strings?

Boolean Variables

  • Does the program use additional boolean variables to document conditional tests?
  • Does the program use additional boolean variables to simplify conditional tests?

Named Constants

  • Does the program use named constants for data declarations and loop limits rather than magic numbers?
  • Have named constants been used consistently—not used as named constants in some places and as literals in others?

Arrays

  • Are all array indexes within the bounds of the array?
  • Are array references free of off-by-one errors?
  • Are all subscripts on multidimensional arrays in the correct order?
  • In nested loops, is the correct variable used as the array subscript, avoiding loop-index cross-talk?