Citing External Sources in Code Comments
Citing sources in your code is a normal, expected part of professional software development. It is not an admission of wrongdoing. It shows that you understand what you used and why, and it helps your instructor evaluate your work accurately.
Where to Place Attribution Comments
Put attribution comments near the code they influenced, not at the top of the file. This makes it easy to understand the connection between the source and what you wrote.
What to Include
Identify the source, and briefly explain how it shaped your understanding, design, or implementation. One or two lines is enough.
When to Cite
You do not need to attribute every line of code. Cite a source when it meaningfully influenced how you approached a problem, understood a concept, debugged an issue, or made a design decision. When in doubt, include the citation.
Examples
The examples below show the expected format. Copy and adapt them as needed.
Website or Documentation Source
// Source: https://docs.oracle.com/javase/8/docs/api/java/io/BufferedReader.html
// Used to understand how readLine() returns null at the end of a file
while ((line = reader.readLine()) != null) {
// process line
}
Classmate Discussion
// Classmate: Discussed approaches for splitting lines into tokens with Alex T.
// We discussed ideas only. No code was shared.
String[] tokens = line.split("\\s+");
AI Tool Assistance
// AI: Used Claude to understand why try-with-resources closes resources in reverse order
// Prompt: "Why does try-with-resources close resources in reverse order?"
try (BufferedReader reader = new BufferedReader(new FileReader(file));
PrintWriter writer = new PrintWriter(new FileWriter(output))) {
// reader and writer are closed automatically, writer first
}