Computation and programming are increasingly inescapable in modern Earth Sciences, but scientists and researchers receive little or no formal software engineering or programming training. At the same time, research into the reproducibility of other academic papers exposing disappointingly low rates of repeatability and high-profile retractions due to computational or data errors increase the onus on researchers to write repeatable, reliable, even reusable programs; in other words, "write better code".
Software engineering has plenty to say on the matter of "better code": metrics, methodologies, processes, tools... Of course, none are indisputable and none provide absolute guarantees. One seemingly obvious technique - testing - has enjoyed a renaissance in incarnations such as unit testing, and with approaches such as test-driven development (TDD) and behavior-driven development (BDD).
Based on our experience at the National Snow and Ice Data Center (NSIDC) with unit testing, TDD and BDD, we present a set of recommendations to scientific and research programmers about some techniques to try in their day to day programming, and possibly provide some inspiration to aim for more comprehensive approaches such as BDD. We will highlight some use cases of various types of testing at the NSIDC, discuss some of the cultural and management changes that occurred for programmers, scientists and project managers to consider and adopt processes such as TDD, make recommendations about how to introduce or expand rigorous code testing practices in your organization, and discuss the likely benefits in doing so.
Ian Truslove is a software engineer at NSIDC, working on services-based web applications. He has worked in various software roles for over twelve years, and has been learning and practicing agile development practices for the last seven.
Erik Jasiak is the Head of Software Development and Portfolio Manager at NSIDC, where he is responsible for managing, leading, and coordinating development efforts across projects. He has worked in the technology industry for seventeen years in both the public and private sector; he started using iterative development practices back when they called it "Extreme Programming" in 2000, and been working to revamp software and technology cultures in the Earth and Space Sciences over the last three years.