Pages Menu
Chitu Okoli chitu.okoli.org

Posted on Jul 13, 2013 in Computers and the Internet

How to cite code borrowed from other sources

Computer program code

To cite code, there is no need to copy the original; a link suffices

To cite code borrowed from other sources, the main concern in avoiding plagiarism is that you acknowledge that it is not your own work. Most fundamentally, you need to add a comment in your code that makes two things clear:

  1. The code you are using is not your own original work; and
  2. what is the source of the code you borrowed, usually indicated with a URL.

For example, suppose I am writing a JavaScript program. I need a function that sorts an HTML table by columns, and I find the following code on the site http://example.com/sort.js:

function sortTableArray(tableToSort) {
  // Here is the code of the original function
}

If I borrow this function exactly in my own code, with no changes (except perhaps changing the function name), then I could cite it like this:

/* Code copied from function sortTableArray obtained from http://example.com/sort.js */
function sortTable(tableToSort) {
  // Here is the code of the original function
}

If I borrow this function with some modifications (whether minor or major) in my own code, then an appropriate way to cite code modified in this manner would be:

/* Code modified from function sortTableArray obtained from http://example.com/sort.js */
function sortTable(tableToSort) {
  // Here is the code of the original function
}

Note that the only difference between the two ways to cite code is that exact copies say “code copied from…” and modifications (whether minor or major) say “code modified from …”. In either case, you satisfactorily acknowledge that you are not the original author of this portion of code and you reference the source so that others can find it.

Discover more from Chitu Okoli

Subscribe now to keep reading and get access to the full archive.

Continue reading