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.