Before we discuss how to properly cite, let’s review when it’s appropriate to cite. As a rule of thumb, if the code contains common knowledge that any junior developer would know, then it’s not necessary to cite the reference code. That being said, if there is ever a doubt as to whether or not a citation is needed, add the citation. Your integrity as a programmer is priceless and you should place yourself in a position where you could be accused of plagiarism. Whether you are using a complete code block, or a section of code, you must cite where you found the information.
Open Source Software
Open-source software (OSS) is a software released under a license with a copyright holder. OSS is typically shared publicly and anyone can access, use and modify the source code.
Code from an Open Source Software is arguably the easiest to cite because they come with ready-to-use citations. OSS code comes with a distribution license, which includes the licensing terms and citations. It’s best to store the license in the file with the code.
GitHub makes citations easy by allowing the original creator(s) to add a
CITATION.cff file. The
CITATION.cff the file is a plain text file where the creator can specify how they would like to be credited and what to include in the citation.
CITATION.cff files are currently supported by GitHub, Zenodo, and Zotero.
Below is an example
CITATION.cff file from GitHub to use as reference:
message: "If you use this software, please cite it as below."
- family-names: "Lisa"
- family-names: "Bot"
title: "My Research Software"
Place the information contained in the
CITATION.cff file on the page where the code is used.
Bonus: When a GitHub repository includes a
CITATION.cff file following the example format, it will automatically both APA and BibTeX citations.
When you search for coding help on your favorite search engine (Google), your top results is likely several different posts on Stack Overflow. Founded in 2008, Stack Overflow has had over a decade to build up a library of programming Q&A’s, and whatever question you have has likely already been answered. Because of this, it’s common for programmer to find and copy code directly from the website.
Again, a website URL and date accessed would suffice, but if you want to cite the post properly then you’ll need to include some more information, including all of the posts you referenced.
/* Original code Copyright (c) 2011 cdiggins Modified code Copyright (c) 2016 Shane Celis, @shanecelisLicensed under the CC-BY-SA 3.0 Original code posted to this question and answer from stackoverflow.com where user contributions are licensed under CC-BY-SA 3.0 with attribution required. : https://stackoverflow.com/users/184528/cdiggins : https://twitter.com/shanecelis : http://creativecommons.org/licenses/by-sa/3.0/ : http://stackoverflow.com/questions/3151702/discriminated-union-in-c-sharp : http://stackoverflow.com/a/7302957/6454690 */ /* CHANGES ------- May 21, 2016 [ENHANCEMENTS] * Removed 'dynamic' keyword and made other small changes to support Unity. (Could be considered a degradation rather than an enhancement.) [BUG FIXES] * Now works with non-static delegates. * Throws exception on `Match<void>` to stop Unity Editor from crashing. */ Conclusion The reuse of code can be seen as good practice but copying other peoples computer code without citing it correctly may be a plagiarism violation. It is not always clear how to correctly reference programs and source code. The information on this page explains how to cite programs and source code correctly within reports and in the source code itself. Remember, your professor is the final expert in this matter. When in doubt, consult.