Teaching material on scientific computing has traditionally been very focused on the mathematics and the applications, while details on how the computer is programmed to solve the problems have received little attention. Many end up writing as simple programs as possible, without being aware of much useful computer science technology that would increase the fun, efficiency, and reliability of the their scientific computing activities.
This document demonstrates a series of good practices and tools from modern computer science, using a very simple mathematical problem with a very simple implementation such that we minimize the mathematical details. Our goal is to increase the technological quality of computer programming and make it match the more well-established quality of the mathematics of scientific computing.
More specifically we address the following topics:
- How to structure a code in terms of functions
- How to make a module
- How to read input data flexibly from the command line
- How to create graphical/web user interfaces
- How to write unit tests (test functions or doctests)
- How to refactor code in terms of classes (instead of functions only)
- How to conduct and automate large-scale numerical experiments
- How to write scientific reports in various formats (LaTeX, HTML)
The conventions and techniques outlined here will save you a lot of time when you incrementally extend software over time from simpler to more complicated problems. In particular, you will benefit from many good habits:
- new code is added in a modular fashion to a library (modules),
- programs are run through convenient user interfaces,
- it takes one quick command to let all your code undergo heavy testing,
- tedious manual work with running programs is automated,
- your scientific investigations are reproducible,
- scientific reports with top quality typesetting are produced both for paper and electronic devices.