Quantcast
Channel: How to share computer code? - Academia Stack Exchange
Viewing all articles
Browse latest Browse all 9

Answer by cjs for How to share computer code?

$
0
0

There's lots of good advice in the various answers; I'm going to address only point 3, "How do I make it easy for other people to run the code?"

The answer here is to automate as much as possible. This will have the added benefit of making your life easier, too, as you'll spend less time typing (and retyping) magic incantations and checking output.

Start, as early as possible, with a top-level script (I usually call it Test) that builds and tests all your code. (This is always the first thing I write.) In your case it sounds like it's too late to start with it, but add it now and grow it in the same way.

Every time you do a new checkout or clone of your repository, start by running the Test script. When it reaches the first error of any kind, consider how you could tweak the script to get rid of that error (if that's easy to do) or detect the error condition and give some informative message to the user. For example, if you depend on libfrozzit and its header files being present for you to compile, you may not be able to install it, but you can at least try to check for its presence and, if absent, fail with, "libfrozzit not found. Install with apt-get frozzit-dev or yum install frozzit-devel?"

Write tests of any kind, whether basic unit tests or functional tests, for your code. Even picking the simplest function and sending one value through it, or running myprogram --help and ensuring it prints any message whatsoever, means you've started a test framework and makes it much, much easier for someone else to come along and add a test. If you can get up to, say, 5% test coverage of your code that's a significant benefit because even that much will be a great help to someone who's wondering if the code was built properly.

Making code easy for others to build and run isn't magic, and can't be done by waving a wand or running a special tool. It's a matter of saying, every time you find yourself doing a manual tweak to get things to work, no matter how simple, asking yourself "how would I automate away the need for that manual tweak"?


Viewing all articles
Browse latest Browse all 9

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>