Ten simple rules on writing clean and reliable open-source scientific software
- PMID: 34762641
- PMCID: PMC8584773
- DOI: 10.1371/journal.pcbi.1009481
Ten simple rules on writing clean and reliable open-source scientific software
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.
Conflict of interest statement
The authors have declared that no competing interests exist.
Similar articles
-
Evaluation of Rust code verbosity, understandability and complexity.PeerJ Comput Sci. 2021 Feb 26;7:e406. doi: 10.7717/peerj-cs.406. eCollection 2021. PeerJ Comput Sci. 2021. PMID: 33817049 Free PMC article.
-
An open-source natural language processing toolkit to support software development: addressing automatic bug detection, code summarisation and code search.Open Res Eur. 2023 Oct 27;2:37. doi: 10.12688/openreseurope.14507.2. eCollection 2022. Open Res Eur. 2023. PMID: 38654755 Free PMC article.
-
Bionitio: demonstrating and facilitating best practices for bioinformatics command-line software.Gigascience. 2019 Sep 1;8(9):giz109. doi: 10.1093/gigascience/giz109. Gigascience. 2019. PMID: 31544213 Free PMC article.
-
SciPy 1.0: fundamental algorithms for scientific computing in Python.Nat Methods. 2020 Mar;17(3):261-272. doi: 10.1038/s41592-019-0686-2. Epub 2020 Feb 3. Nat Methods. 2020. PMID: 32015543 Free PMC article. Review.
-
Standards, dissemination, and best practices in systems biology.Curr Opin Biotechnol. 2023 Jun;81:102922. doi: 10.1016/j.copbio.2023.102922. Epub 2023 Mar 31. Curr Opin Biotechnol. 2023. PMID: 37004298 Free PMC article. Review.
Cited by
-
A rubric for assessing conformance to the Ten Rules for credible practice of modeling and simulation in healthcare.PLoS One. 2025 Jun 25;20(6):e0313711. doi: 10.1371/journal.pone.0313711. eCollection 2025. PLoS One. 2025. PMID: 40560895 Free PMC article.
-
A how-to guide for code sharing in biology.PLoS Biol. 2024 Sep 10;22(9):e3002815. doi: 10.1371/journal.pbio.3002815. eCollection 2024 Sep. PLoS Biol. 2024. PMID: 39255324 Free PMC article. Review.
-
Evaluating LC-HRMS metabolomics data processing software using FAIR principles for research software.Metabolomics. 2023 Feb 6;19(2):11. doi: 10.1007/s11306-023-01974-3. Metabolomics. 2023. PMID: 36745241 Free PMC article.
-
ENCORE: a practical implementation to improve reproducibility and transparency of computational research.Nat Commun. 2024 Sep 16;15(1):8117. doi: 10.1038/s41467-024-52446-8. Nat Commun. 2024. PMID: 39284801 Free PMC article.
-
Toward practical transparent verifiable and long-term reproducible research using Guix.Sci Data. 2022 Oct 4;9(1):597. doi: 10.1038/s41597-022-01720-9. Sci Data. 2022. PMID: 36195618 Free PMC article.