Coding reproducibly

April 05, 2017 Kosmas D

How to ensure your code is reproducible (and avoid disaster)

When an individual programs a piece of code, be it for university, research or hobby, it is very likely that the code will change multiple times. A code can always be 'better', by adding improved functionality, fixing bugs, adding comments, etc... In all these changes it is important that one keeps track of which versions work, so that if any change inadvertently brings new errors, the mistake can be corrected. One way of doing this would be to save multiple versions of the same file. However, as many of you may know first hand, one will end up having tenths of different versions of the same file. "So which version of my code did I use three weeks ago? Hm..........".

There is a better way to control the version of your code files. In fact, the same approach can be used with any text file, such as your report. Version control systems have been developed in order to track changes in text files. Effectively, such tools monitor the differences between text files in the different versions that one 'saves'. Then, one can compare the current version with the version of two weeks ago. This alows easier troubleshooting if new bugs appear after certain modifications. You only need one version of the actual file, and the version control tool is doing the rest.

One such version control system is called Git. Git is a tool that you can install in your PC. You may also be familiar with Github. Github is an online hosting platform for Git repositories. You make a Git repository in your computer, and you can then upload it in Github. Github is very convenient for collaboaration as well, as different users can copy the full repository and make changes in the files (that will be tracked).

Leaning Git is not very difficult for basic use. You first need to learn how to 'save' the Git-way, which is in adition to the save function of your e.g. Word program. Subsequently, a few more commands allow you to inspect differences in the text files and go back in time, if you want to restore your files to an earlier version.

Using Github is also a very good way of backing up your files. You should know that, having  a copy of your files in an external hard drive, next to your monitor, is NOT a backup. This is a second copy, which will be destroyed if there is a fire or earthquake. A backup is meant to be remote, so that it is not suceptible to the same physical disasters as your original copy. Github provides free public repositories, and if you want your private ones you can purchase them separately.


Have you thought about online lessons?

Online tuition gives you access to brilliant tutors across the country
Connect one-to-one with a tutor or share your lesson with a group for 50% of the tutor's hourly rate! Find a Tutor for One-to-One Find an Online Study Group

Want to know more?

Visit Kosmas's profile to find out more and send a message.

Visit Kosmas's Profile

Resources others found helpful

Dyslexia Symptoms in Teenagers and Adults

Signs and symptoms that suggest dyslexia in teenagers and adults

learn more

describe a celebrity

adjectives and family members

learn more

KS3 Maths SATS's past papers

Free past SAT's test papers with mark schemes included

learn more

Emanuel School Sample Paper Maths and Marks Scheme

This is a sample paper and marks scheme for year 7 11+ entry for Emanuel School.

learn more

Free resources, revision notes and past papers for students

Find revision guides, exam papers and sample essays amongst hundreds of free resources available to students.

Find resources any subjects

Maths resources | Science resources | Music resources | Spanish resources | English resources | French resources