Code Comments: How to Use Them and Why?

What is a common mistake I see coding beginners make?

…not putting any or enough code comments. And it’s understandable because when I first learned how to code, I thought code comments were pointless. Why would you put a comment in your code when you can just figure out what the code is doing just by looking at it? But as I got more experience in coding, I started to see their value and appreciate them more.

And that’s because code comments are like messages from the past. When you read them, it’s like a developer from the past is telling you about his or her code. Oftentimes, it saves you a ton of time because code can be complex if you don’t have a clue of what’s going on. A simple code comment can give you a clue or tell you exactly what you need to know to understand that piece of code.

They are also like messages to the future. When you write a code comment, you tell important information to the future person who looks at your code. Oftentimes, the future person who looks at your code is you! And your future you will thank you.

In this video, you’ll learn:
✅ Why code comments are useful
✅ When to use them
✅ How to use them