S
3 months ago
Selmacountry asked

How important are comments?

Kelish Rai
Expert
2 weeks ago
Kelish Rai answered

The importance of comments depends on whether you (or someone else) will need to read your code again in the future—which is almost always the case in real-world programming.

If you're working on a project with others, comments make it much easier for teammates to understand your code’s purpose and logic. Even if you're working alone, comments help you remember why you wrote something a certain way—especially if you revisit the code weeks or months later.

When to use comments:

  • To explain why something is done (not just what is done—that should be clear from good code and variable names).

  • To clarify complex logic or non-obvious decisions.

  • To mark sections of code like TODOs.

Note: Avoid over-commenting. Good code should be readable on its own, and excessive comments can clutter it. Think of comments as helpful guideposts, not a substitute for clear code.

HTML
This question was asked as part of the Learn HTML course.