Programming Truisms

Testing

Assertions

  • Whenever you assert some condition, make sure that the program fails to meet it at the time when you expect the assertion to fail (i.e. before you’ve implemented or fixed the feature you are testing). Otherwise, if the implementation of the assertion itself is faulty, it will appear as though it is working as intended regardless of the actual behavior.1

Data Analysis

Visualization

  • When creating a complex visualization, get the visualization code (e.g. matplotlib) to render correctly with simplified synthetic data that has the same schematic form as the real data. This will allow you to confirm the visualization is working independently of how the (real) dataset is loaded and structured.

  1. These are sometimes called “evergreen tests”, because they are always “green” (or passing) like the proverbial evergreen tree; example youtube talk link↩︎