Skip to Main Content

Coding integrity

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 2018.)

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 2018.)

Examples 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 2018.)

[ B. D. Owens Library ] B.D. Owens Library | 800 University Dr. Maryville, MO 64468 | 660.562.1193 [ TikTok ] [ Facebook ] [ Instagram ] [ Spotify ]