4 ms·
I comment for myself first. In my experience, I may not remember what the heck I was thinking writing that code even 5 minutes later. If I ever start wonderin
by forgotmypw17 6y ago
I comment for myself first.
In my experience, I may not remember what the heck I was thinking writing that code even 5 minutes later.
If I ever start wondering what my code is supposed to do, once I figure it out, I comment.
After doing this for a while, I've learned what I'll probably want to know later, and what will seem obvious.
Besides this addition, I think your outline hits the nail on the head.
- anon9001 6y agoI agree with all of that. It sounds silly, but if you can work how you feel into the comment, it's really helpful later on. I like to use tags and sometimes emojis. Just remember that you're talking to future you. Usually specific versions of these: * `// XXX this is a bad thing that we can't improve yet, sorry` * `// TODO this thing works, but it should also do something else soon` * `// FIXME this is definitely broken` * `// HACK here comes some magic stuff, but it works...` * `// NOTE this is non-traditional or non-obvious, so let me explain` If you do that, it makes it easy to search for tech debt too.
- barry27 6y agoi agree with all of this too. i'd also add that sometimes the comments are there before the code, as i attempt to explain to myself what's going to happen next.