Skip to content

Comments

What are Comments?

Comments are notes written by the programmer to explain what the code is doing. They are ignored by the computer and do not affect how the program runs.

Why use Comments?

  1. Explain "Why": Don't explain what the code does (the code does that); explain why you wrote it that way.
  2. Organization: Use them to mark sections of a large file.
  3. Debugging: Temporarily "comment out" code to prevent it from running while testing.
  4. Collaboration: Help other developers understand your logic.

Best Practice

Write clear, concise comments. If your code is so complex it needs a paragraph of explanation, consider refactoring the code to be simpler!