University of Canberra
Skip to Main Content

UC Referencing Guide

Computer Code / Source Code - In-text Citation

When using computer code from another source you should:

  • Cite the code that has been used, including snippets and adapted code.
  • Include the URL and date of retrieval in the citation, along with any extra details as needed.  Include the wording "Adapted from:" or "Based on:" for modified code.
  • Follow the terms of the open source licence that applies.  Good practice is to duplicate the copyright in your code, and / or store the licence in a file with the code.
  • Follow any guidelines from the unit convener.
Examples of citing code sources:
Example 1

In describing the class PluginProxyUtil in the Apache Project source code, the developer cites the source as a post in a forum and includes the URL, author and date:

/**
* A utility class that gives applets the ability to detect proxy host settings.
* This was adapted from a post from Chris Forster on 20030227 to a Sun Java
* forum here:
http://forum.java.sun.com/thread.jspa?threadID=364342&tstart=120
[…]
*/

(Source: Apache Project source code http://svn.apache.org retrieved in July 2019.)

Example 2

In the function OutputTraceToStream in the Google Chrome stack_trace_win source code, the developer cites the source code as the Microsoft Developer Network and includes a URL:

// Code adapted from MSDN example:
// http://msdn.microsoft.com/en-us/library/ms680578(VS.85).aspx 

(Source: https://github.com/adobe/chromium/blob/master/base/debug/stack_trace_win.cc retrieved in July 2019.)

Example of open-source-licensed code:

At the top of the Google Chrome stack_trace_win source file, note the copyright and reference to the open source license:

// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

If you incorporate this code into a program, you should follow the terms outlined in The Chromium Authors' open source license file, which is shown below. While this license only requires that you duplicate the copyright and license if you are redistributing the code, it is good practice to always duplicate the copyright in your code, and/or store the license in a file with the code. This way, if you want to redistribute the code later, intellectual property reviewing becomes much easier.

// Copyright (c) 2014 The Chromium Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
//* Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//* Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//* Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//

(Source: The Chromium Authors license file https://src.chromium.org/viewvc/chrome/trunk/src/LICENSE retrieved in July 2019.)

(These examples are taken from Academic Integrity at MIT: A handbook for students. https://integrity.mit.edu/handbook/writing-code)

Computer Code / Source Code - Referencing

There are no guidelines for referencing computer or source code.  The Library is using the guidelines for computer programs.

Format

Author. Year of publication. Title of Work. Version. Location: Publisher. Description. Accessed Month Day, Year, URL

Example

Smith, P. 2020. GraphicsEditor. Version 3.0. Graph1. Source code lines 2-5. Accessed January 15, 1021, http://Graph1.com/GraphicsEd