Starting in the spring 2013, I videotaped the lectures for my MATH 676: Finite element methods in scientific computing course at the KAMU TV studio at Texas A&M. These are lectures on many aspects of scientific computing, software, and the practical aspects of the finite element method, as well as their implementation in the deal.II software library. Support for creating these videos was also provided by the National Science Foundation and the Computational Infrastructure in Geodynamics.
Note 1: In some of the videos, I demonstrate code or user interfaces. If you can't read the text, change the video quality by clicking on the "gear" symbol at the bottom right of the YouTube player.
Note 2: deal.II is an actively developed library, and in the course of this development we occasionally deprecate and remove functionality. In some cases, this implies that we also change tutorial programs, but the nature of videos is that this is not reflected in something that may have been recorded years ago. If in doubt, consult the current version of the tutorial.
Lecture 24: Best programming practices: Defensive programming and other ways to avoid bugs
Inexperienced programmers often think that experienced programmers do not make mistakes or introduce bugs. However, while they may make fewer mistakes, the primary difference in my view is simply that they have better ways to deal with them: they know they will make mistakes and change their programming practices to either avoid common pitfalls, or to "hedge" against them by making it easy to discover bugs. In the latter case, the result is not that they start out with fewer bugs, they simply get rid of them faster. (It is certainly also true that one figures out faster what exactly the problem is and how to fix it if one has years of experience and has seen every bug at least once before — in fact, made every mistake at least once oneself.)
In this lecture, I consider some of the strategies that have proven to be very useful in writing good code. The goal is to avoid bugs to begin with, and to make finding bugs easier if they do happen.
In practice, dealing with mistakes is as much a question of skills and techniques, as it is of mindset. You might want to take a look at this blog post I wrote for the Better Scientific Software (BSSw) blog in 2020 and that talks about exactly this point.
Slides: click here