What to look for in the algorithm:

  • Algorithms must be language independent and general in nature
  • Depending on the algorithm, You can leave out the declaration of variables. This should only be the case if it doesn’t compromise the readability of the algorithm.
  • In this example, the products are described in detail. In real world, this would most likely be¬†described as one action statement and be as abstract as possible. This would lead to another work flow, where the prices are gathered from a distributors database and populated into the systems.
  • Algorithm skips some of the products that are used in the code just to be more compact (repeat process)

What to look for in the code:

  • Notice the elements from the coding style – file header, naming the variables, indentation, placement¬†of spaces.
  • In general, switch() statements require the cases to be broken off with break; to avoid going through the rest of the cases underneath it.
  • Simple error handling should be used for now – e.g. checking for zero or negative results that might cause errors etc.