Skip to content

Sharing your code

Sharing your code is essential for making your research open and reproducible, it allows other researchers to build on your work, to understand it and to verify your findings.

What to do to share your code

If you can, use open source tools

There are several reasons why people choose a programming language or a software: simplicity, familiarity with the tool, lab standard and many others. These are all valid reasons for choosing a tool, but if you want to ensure that your research is open and transparent, you should also consider whether a tool is open source. Open source softwares grant you access to the source code and freedom to use, modify and distribute them.
As a consequence, if you create some new code with an open source language and make it publicly available, anyone else is allowed to use it freely. On the contrary, proprietary programming languages and softwares require the user to buy a license or to use a license from their institution, thus contravening to the fundamental openess principle of science.

Document your code

Code documentation is an essential prerequisite to make your research transparent and replicable. Without a decent documentation other researchers might be unable to use your code.

Documenting your code is not only advantageous for other potential users, but also for you. It often happens to forget how a piece of code works, by providing good documentation you will save time and effort to you and other users.

Comment your code: The best way to start documenting your code is to comment each essential piece of it while your are still programming:

  • Provide explanations about inputs, outputs and types for functions and classes according to the language style.
  • Provide one or more toy examples that the user can easily run.
  • Provide explanations for lines of code that might have some criticalities, or some peculiarities that might be hard to figure out.

README file: A README file (as Markdown) is one of the most common way to document code. It should include:

  • A brief introduction explaining the scope of the code.
  • An installation procedure, the list of dependencies (libraries needed for the code to run) and requirements (e.g. specific version of a programming language and/or libraries).
  • A simple description of the code structure, especially if your code contains different interconnected parts.
  • A usage description and a working example.
  • Acknowledgements.

Choose a code hosting platform

Github and Gitlab are just a few of the platforms that allow code sharing, such platforms, however, are not just public storages for code, but they are tools for collaborative projects. The advantage of using such platforms during your research are diverse:

  • They allow to share and document your code with your publication.
  • They rely on git, meaning that you can modify and keep track of your code locally through git and transfer (push) your changes to the version of your code hosted on Github or other platforms.
  • They allow to work easily on the same project with your collaborators.
  • They give you a free and safe backup for your code.
  • They allow other people to use your code, help you to find potential issues and improve your code.

Provide a license

Coming soon...

Share your environment

Coming soon...