Python and javascript assessment
COMSC: Guidance on Referencing in Code.
Cardiff University has in place an unfair practice procedure that covers what will happen if a student acts
in a way “that might obtain for him/herself or for another, an unpermitted advantage or a higher mark
or grade than his/her abilities would otherwise secure”. The guidance in this document, designed to
help students avoid this, should be read in conjunction with:
The information on Unfair Practice available on the Student Intranet:
https://intranet.cardiff.ac.uk/students/study/exams-and-assessment/sitting-your-
exams/cheating-and-unfair-practice
The Cardiff University regulations on unfair practices:
https://intranet.cardiff.ac.uk/intranet/students/documents/exams-and-assessment/1.11-
Unfair-Practice-Procedure.pdf
Why would you copy code in an assignment?
A lot of large-scale software development involves the reuse of smaller chunks of code, which is then
adapted to work in conjunction with other small pieces of code. Sometimes this reused code is within a
library module and sometimes that code is found on a tutorial web site like MDN or a Q&A site like Stack
Overflow.
Depending on the assignment you are set, you may feel that you should reuse code from some of these
sites in order to: hasten the development of your application, experiment with unused technology, or to
fix a problem that you are struggling with.
Whether or not you should reuse code will depend on the assignment set. You will not gain any marks
for writing the copied code (because you didn’t) but you will gain marks for integrating it into your
solution therefore you must consider the aim and the marking criteria of the assignment.
As a simple example to illustrate the point:
Your Java assignment is to write a java programme to perform a bubble sort on an array of
numbers.
You copy (and reference) a code snippet from Stack Overflow that performs a bubble sort on an
array of numbers carefully putting the algorithm into the method signature required.
This has missed the point of the exercise, you gain no marks for the production of the algorithm
and the integration is very minimal so will probably get no marks for that.
However, if:
Your Commercial Applications assignment is to create a website that will collect student grade
data, store it, and be able to export that formatted data in a JSON file sorted by grade.
You copy (and reference) a code snippet from Stack Overflow that performs a bubble sort on an
array of numbers carefully putting the algorithm into a method signature, then integrate this
method into your project.
You will not get the marks for coding a bubble sort, but you will get the marks for the integration
of that code into a bigger project. You will get the marks for deciding to use a bubble sort
(although, probably, more marks would have been given for a different approach). In all, unless
the assignment specified otherwise, it is likely you would see little difference in your mark if you
had written it yourself.
How to Reference Code in Your Code
Just as when you include other people’s ideas and words in your writing you must attribute them to the
author, when you include other people’s code within your code you must do the same; otherwise, you
are pretending that this is your own work.
If your lecturer does not explicitly define how they wish you to cite any copied code there are some
general examples given below.
It does not take much to reference code in your code. If you have copied a chunk of code then you can
reference this in a comment, close to where the copied code has been included. You should include as a
minimum some general information about the code copied, the URL where you copied the code from,
and the date accessed e.g.
// Code to perform bubble sort
// taken from Stack Overflow post by A.C Oder 20-6-2004
// accessed 4-9-2018
// https://stackoverflow.com/questions/........./bubblesort-implementation
[[ CODE here ]]
// end of referenced code.
OR
You could include this information in the method or function’s documentation comment, e.g.
/**
* Returns a sorted array
* This code was taken from Stack Overflow post by A.C Oder 20-6-2004
* accessed 4-9-2018
* https://stackoverflow.com/questions/........./bubblesort-implementation
*
* @param input unsorted array
* @return sorted array
*/
You may have had to adapt a lot of the copied code to make it fit with what you needed. In which case
you could state that the code has been adapted and highlight the lines / chunks you change so that the
marker can credit you for that work.
/**
* Returns a sorted array
* This code was adapted from Stack Overflow post by A.C Oder 20-6-2004
* accessed 4-9-2018
* https://stackoverflow.com/questions/........./bubblesort-implementation
* Added code to allow for sorting high to low or low to high
* see further comments for adaptions
*
* @param input unsorted array
* @param true high to low, false low to high
* @return sorted array
*/
Then in the code you should highlight the parts that you wish to gain credit for adapting via additional
comments.
Further resources:
A guide from MIT on referencing in code: http://integrity.mit.edu/handbook/writing-code