In software development, the reuse of code is a good practice. In addition, collaboration among programmers is almost the norm. However, in a learning environment for an assignment, lab or exam you might be required to write your program code individually (e.g. your Java program) from scratch and copying other people's code might not be allowed. The purpose of the exercise might be for you to come up with the program code yourself through critical thinking and individual experimentation.
Where an assignment or lab permits copying or modifying code by other people, it is important to cite where you got the code from. You may be charged with plagiarism if you fail to do so. Plagiarism can be broadly defined as taking credit for academic or intellectual work that is not your work. It is considered a serious academic offence at Langara and at other post-secondary institutions.
An added benefit of citing correctly is that it makes your code easier to maintain.
Remember, your instructor is the final expert in this matter. When in doubt, consult your instructor, especially as to whether any reference to other work is allowed.
As a student, it can be difficult to to know what resources need to be cited and what resources don't. Generally, if you used a function or algorithm that you did not create and it came from someone else, then this should be cited so as to give the creator credit. This applies also to code given in class and to code copied from a textbook.
Changing variable names or any non-algorithm elements (often refered to as cosmetic) does not make the code yours. You still need to cite where you got the code.
Ideas and programs that are "common knowledge" do not generally need to be referenced or cited. If there is only one way to program for a specific task and this is so commonly used, then it may not need to be cited. A good example of this is a "hello world" program such as the following (in Java):
class HelloWorld { public static void main (String[] args) { System.out.println ("Hello World"); } }
Adapted with permission from Kirkwood, Patricia. (2015, June 3). Citing Programming Codes. U. of Arkansas.
Retrieved from http://uark.libguides.com/c.php?g=78829&p=506916
To cite either a complete computer program or just a program fragment, you will need the following information. Provide as much as available.
Provide the citation information as a comment placed above the reused code.
/* Title: <title of program/source code> Author: <author(s) names> Date: <date> Code version: <code version> Type: <type> Availability: <where it's located> */
Adapted with permission from Kirkwood, Patricia. (2015, June 3). Citing Programming Codes. U. of Arkansas.
Retrieved from http://uark.libguides.com/c.php?g=78829&p=506916
Provide as much information as available. If there is no author, version number or date, leave it out.
/* Title: Selection Sort Type: Source Code Availability: http://www.algolist.net/Algorithms/Sorting/Selection_sort */ public void selectionsort(int[] arr) { int i, j, first, tpm; etc...
Use the HTML comment to provide credits and note adaptations.
<!--Adapted from: Title: Region GeoCharts Date: July 20, 2015 Type: Source Code Availability: https://developers.google.com/chart/interactive/docs/gallery/geochart?hl=en -->
<script language="javascript" src="liveclock.js"> /* Live Clock Script- By Mark Planchetta (astro@bigpond.net.au(c)) based on code from DynamicDrive.com For full source code, 100's more DHTML scripts, and Terms Of Use, visit http://www.dynamicdrive.com */
/* Title: displayBalance Author: Instructor Name Date: 25 June 2015 Type: Source Code Availability: Provided for assignment 1 on 25 May 2015 for CPSC 1181. */ Void displayBalance() etc...
In addition to the title of the program or source code, add the video title.
/* Title: binarysearch.cpp Author: Peggy Fisher Date: May 23, 2014 Type: Source Code Availability: Up and Running with C++. Lynda.com, 2014. Retrieved from http://www.lynda.com/C-tutorials/Up-Running-C/167922-2.html?org=langara.bc.ca */ bool search (int[], int, int); int main() { srand (time (0)); int nums [10]; etc.....
Note that you can find a link to the video by clicking the "Share" button and selecting a "copy link for someone within Langara College".
/* Title: Row-by-row Processing Author: Djoni Darmawikarta Date: March 2014 Type: Source Code Availability: Oracle SQL: A Beginner's Tutorial. Brainy Software, 2014, p. 98. Retrieved from: http://site.ebrary.com/lib/langara/detail.action?docID=10882075 */ BEGIN For inv IN (SELECT C_no, etc.....