F
20
c/coding-for-beginnersivan462ivan46219d agoMost Upvoted

I finally saw how bad my code comments were after helping a friend

My buddy asked me to look at his beginner Python script last weekend at a coffee shop near downtown. I opened his file and everything was clear because he wrote short notes about what each function did. Then I looked at my old projects and realized I had zero comments or just stuff like 'this works' which is useless. Now I am going back through my code and adding real explanations for future me.
3 comments

Log in to join the discussion

Log In
3 Comments
the_lucas
the_lucas18d ago
@the_cameron your comment made me realize how bad my git commit messages are too, not just the code comments.
8
the_cameron
Man that hits close to home because I did the exact same thing a few years back when I was helping a friend learn JavaScript. I saw how clean their comments were and felt bad about my own messy files so I went through every project and rewrote the comments like I was talking to someone who had no idea what the code did. It was a pain at first but now when I come back to old code after six months I actually understand why I did things a certain way. I also started writing comments as I go instead of waiting until later because future me is lazy and won't do it. It's a small thing but it saves so much time when you're debugging or adding features later on.
3
zarat37
zarat3718d ago
Honestly I used to be the opposite, I always thought comments were a waste of time because the code should speak for itself. But reading your comment and the person above you made me go back and look at some of my old projects from last year and I literally couldn't figure out what half of it did. So I spent last weekend cleaning up all my old comments and now I'm kind of mad at myself for not doing it sooner because I actually see how much clearer it makes things. Especially your point about writing comments as you go, I always told myself I'd do it later and then future me just didn't.
2