Skip to Main Content
Go to the Langara College website. Opens in a new window
Go to the Langara Library website. Opens in a new window

Computer Science

A general guide to Computer Science

Why and When to Cite

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.

Why cite

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.

Knowing when to cite

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):

Examples of common Java code
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

What and How to Include

To cite either a complete computer program or just a program fragment, you will need the following information. Provide as much as available.

What you need

  • Title of program/source code
  • Author(s) name (Individual or corporation)
  • Date (when the program or program fragment was created, published or last revised)
  • Code version (2.0, 1.150
  • Type (e.g.pseudo-code, source code)
  • Availability (e.g. program publisher, title of video or book and publisher, a book's page numbers, URL of Webpage, online video or book)

How to do this

Provide the citation information as a comment placed above the reused code.

Code citation example
/*
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

Specific Examples

Code from the Web

Provide as much information as available. If there is no author, version number or date, leave it out.

Code with fields left 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...

 

Note for Web development assignments

Use the HTML comment to provide credits and note adaptations.

HTML comment example
<!--Adapted from:

Title: Region GeoCharts
Date: July 20, 2015
Type: Source Code
Availability: https://developers.google.com/chart/interactive/docs/gallery/geochart?hl=en
-->

 

Include attribution and instructions

Example of retaining information from: http://www.dynamicdrive.com/dynamicindex6/clock2.htm
<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
*/

 

Code provided in class

Citing code provided in class example
/*
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...

 

Code from Lynda.com

In addition to the title of the program or source code, add the video title.

Example of Lynda.com citation entry.
/*
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".

 

Code from an online book

Online book code citation example
/*
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.....