Sample code for chapter 4 of my book Taming the Bad Code.