Software Best Practices and Challenges
Safe code storage
- In addition to storing your code locally, it should consistently be backed up to a remote repository. Here are some popular options:
- Stable versions (i.e. releases) of your code can be additionally backed up to a number of static repositories. Not only does this add another layer of protection, but it also helps make the science you use your code for more reproducible. Here are some commonly-used options:
- If your code has online documentation (e.g. Read the Docs), save them with the Internet Archive's Wayback Machine
Getting your code cited
-
Code citations can be an important metric when deciding what resources to dedicate to a code's
maintenance. Here are some ways to make your code citable without a traditional journal article:
- The Journal of Open Source Software (JOSS), a free, open-access journal that also provides code review.
- The Astrophysics Source Code Library (ASCL), a free code registry for the astrophysics community.
- zenodo, a free code and data registry maintained by the CERN Data Centre
- Additionally, you can help point people to the correct citation for your code. Along with your repository's README, include a CITATION.cff file or a codemeta.json file that tells your users exactly what to cite.
- NOTE: Code that is stored in multiple places (as it should be) often has multiple Digital Object Identifiers (DOIs) minted for a single version of software. The ASCL and NASA Astrophysics Data System (ADS) are currently working on coordinating between DOI creators so that there is a one-to-one relationship between DOIs and unique pieces of software.
Style and Documentation
- Documenting your code can have a dramatic positive effect on your users. It makes your code more usable and much easier to maintain.
- A common way to quickly publish documentation is to use Sphinx to auto-generate a website based on the docstrings in your code. This website can be uploaded to Read the Docs for free to be accessible to the public.
-
To make your source code more readable, it is best practice to follow the PEP-8 Style Guidelines. This is made easier by
using linters and formatters such as:
- autopep8
- pylint
- black