Skip to Main Content
It looks like you're using Internet Explorer 11 or older. This website works best with modern browsers such as the latest versions of Chrome, Firefox, Safari, and Edge. If you continue with this browser, you may see unexpected results.
Writing code is similar to academic writing in that when you use or adapt code; developed by someone else as part of your project, you must cite your source. However, instead of quoting or paraphrasing a source, you include an inline comment in the code. These comments not only ensure you are giving proper credit, but help with code understanding and debugging.
Although it is common practice to adapt code examples found on the web,
- You should never copy code from other students. Your peers are not considered an authorized source.
- You should not simply re-use code as the solution to an assignment. Like academic writing, your code can incorporate the ideas of others but should reflect your original approach to the problem.
When should I cite a source in my code?
- When you copy code from an external source. Whether you are copying a snippet of code or an entire module, you should credit the source.
- When you copy the code and adapt it, you should still credit the source. You were not the original developer of the code.
Use of Open Source Software
When you use code from an open source project, you need both to attribute the source and follow the terms of any open source license that applies to the code you are using. Keep in mind:
When you download the source, the license is typically part of the download.
When you incorporate open-source-licensed code into a program, it is good practice to duplicate the copyright in your code, and/or store the license in a file with the code.
If you don't obtain the license with the download, you should be able to find it on the site of the open source project, such as Apache HTTP Server site or on the Open Source Initiative (OSI) site.
How should I cite the code?
- Generally, the URL and the date of retrieval are sufficient. Add more details if it will help the reader get a clearer understanding of the source.
- If you adapted the code, you should indicate “Adapted from:” or “Based on” so it is understood that you modified the code.
- Your instructor may have specific instructions on how you should or should not cite your sources. If you are not clear on what is acceptable, ask your instructor.