this post was submitted on 06 Jul 2024
1550 points (99.4% liked)

Programmer Humor

19589 readers
578 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 62 points 4 months ago (27 children)

I had a old job that told me that code is "self documenting" if you write it "good enough". And that comments were unnecessary.

It always annoyed the heck out of me. Comments are imo more helpful than hurtful typically.

Is it just me? Or am I weird? Lol.

[–] [email protected] 29 points 4 months ago* (last edited 4 months ago) (2 children)

Comment should describe "why?", not "how?", or "what?", and only when the "why?" is not intuitive.

The problem with comments arise when you update the code but not the comments. This leads to incorrect comments, which might do more harm than no comments at all.

E.g. Good comment: "This workaround is due to a bug in xyz"

Bad comment: "Set variable x to value y"

Note: this only concerns code comments, docstrings are still a good idea, as long as they are maintained

[–] [email protected] 2 points 4 months ago (1 children)

Docstring are user documentation, not comments. User documentation, with examples (tests), is always useful.

[–] [email protected] 2 points 4 months ago

As long as it's maintained. Wrong documentation can often be worse than no documentation.

load more comments (24 replies)