Skip to main page content
U.S. flag

An official website of the United States government

Dot gov

The .gov means it’s official.
Federal government websites often end in .gov or .mil. Before sharing sensitive information, make sure you’re on a federal government site.

Https

The site is secure.
The https:// ensures that you are connecting to the official website and that any information you provide is encrypted and transmitted securely.

Access keys NCBI Homepage MyNCBI Homepage Main Content Main Navigation
Editorial
. 2021 Nov 11;17(11):e1009481.
doi: 10.1371/journal.pcbi.1009481. eCollection 2021 Nov.

Ten simple rules on writing clean and reliable open-source scientific software

Affiliations
Editorial

Ten simple rules on writing clean and reliable open-source scientific software

Haley Hunter-Zinck et al. PLoS Comput Biol. .

Abstract

Functional, usable, and maintainable open-source software is increasingly essential to scientific research, but there is a large variation in formal training for software development and maintainability. Here, we propose 10 "rules" centered on 2 best practice components: clean code and testing. These 2 areas are relatively straightforward and provide substantial utility relative to the learning investment. Adopting clean code practices helps to standardize and organize software code in order to enhance readability and reduce cognitive load for both the initial developer and subsequent contributors; this allows developers to concentrate on core functionality and reduce errors. Clean coding styles make software code more amenable to testing, including unit tests that work best with modular and consistent software code. Unit tests interrogate specific and isolated coding behavior to reduce coding errors and ensure intended functionality, especially as code increases in complexity; unit tests also implicitly provide example usages of code. Other forms of testing are geared to discover erroneous behavior arising from unexpected inputs or emerging from the interaction of complex codebases. Although conforming to coding styles and designing tests can add time to the software development project in the short term, these foundational tools can help to improve the correctness, quality, usability, and maintainability of open-source scientific software code. They also advance the principal point of scientific research: producing accurate results in a reproducible way. In addition to suggesting several tips for getting started with clean code and testing practices, we recommend numerous tools for the popular open-source scientific software languages Python, R, and Julia.

PubMed Disclaimer

Conflict of interest statement

The authors have declared that no competing interests exist.

Similar articles

Cited by

References

    1. Gauthier J, Vincent AT, Charette SJ, Derome N. A brief history of bioinformatics. Brief Bioinform. 2019;20:1981–96. doi: 10.1093/bib/bby063 - DOI - PubMed
    1. Lee G, Bacon S, Bush I, Fortunato L, Gavaghan D, Lestang T, et al.. Barely sufficient practices in scientific computing. Patterns (N Y). 2021;2:100206. doi: 10.1016/j.patter.2021.100206 - DOI - PMC - PubMed
    1. Prlić A, Procter JB. Ten Simple Rules for the Open Development of Scientific Software. PLoS Comput Biol. 2012;8:e1002802. doi: 10.1371/journal.pcbi.1002802 - DOI - PMC - PubMed
    1. Taschuk M, Wilson G. Ten simple rules for making research software more robust. PLoS Comput Biol. 2017;13:e1005412. doi: 10.1371/journal.pcbi.1005412 - DOI - PMC - PubMed
    1. List M, Ebert P, Albrecht F. Ten Simple Rules for Developing Usable Software in Computational Biology. PLoS Comput Biol. 2017;13:e1005265. doi: 10.1371/journal.pcbi.1005265 - DOI - PMC - PubMed

Publication types