1174
Comenting code
(lemmy.ml)
Post funny things about programming here! (Or just rant about your favourite programming language.)
"tells the user the current time" would be an excellent comment for a clock
I'm not the best at commenting my code, but generally I just try to think of what information I'd want to know if looking at this 10 years from now
Imo comments are best used sparingly, don't bother commenting something that anyone with a basic understanding of programming would understand straight away by reading the code
Functions should generally be commented with what parameters are and what they're for, plus what they output
Here's an example where if I were to stumble onto this file 10 years from now, I might think wtf is this looking at it out of context, the comment explains why it exists and what it's used for
(we'll ignore the fact I totally didn't just add this comment because I suck at commenting personal projects)