this post was submitted on 20 Aug 2023
1224 points (98.9% liked)

Programmer Humor

19564 readers
1517 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
[–] Drop_All_Users@lemmy.world 55 points 1 year ago (2 children)

Code documentation is like sex, when it's good it's great, and when it's not good...it's still better then no documentation.

[–] zesty@lemmy.ca 19 points 1 year ago (2 children)

I disagree. When comments are essentially just a rephrasing of the class/method name or arguments it is not helpful and anything that is not helpful is cluttering up the code and making it harder to quickly see what the code is doing. I'd rather have no comments than comments like that.

[–] nothacking@discuss.tchncs.de 12 points 1 year ago* (last edited 1 year ago) (2 children)

I reserve comments for explaining why a section of code is needed or explaining how a complex algorithm works.

i = 0; // Set i to 0 is pointless.

if (last_output_vertex[i] == bounds[i]->length - 1) contibuting_bounds[i] = NULL; // stop outputting a bound if the entire bound has been output is helpful.

[–] JonEFive@midwest.social 7 points 1 year ago (1 children)

Comments can also be useful for explaining what the code is intended to do when debugging.

"Hey this function says it should return the number of apples, but looks like someone, not saying who, but someone had a brain fart and typed oranges in one variable. Who wrote this code anyway?"

-Last edited by JonEFive in 2021-

Past me sucks.

[–] philm@programming.dev 1 points 1 year ago

I think even the second comment is not that helpful.

Just use (boolean) variables that phrase what your comment would explain, often more concise and better to read IMO. Also if the logic is more complex compose multiple named (boolean) variables. I think comments seldom make any sense at all (function doc is a one of the rare cases, mostly for the user of the library in the IDE).

[–] farsightxr20@lemmy.world 5 points 1 year ago

Not to mention the code and comment will inevitably become inconsistent with each other whenever someone forgets to update both.

[–] stebo02@sopuli.xyz 8 points 1 year ago (1 children)
[–] RIPandTERROR@sh.itjust.works 31 points 1 year ago (2 children)

You would know if you had sex

[–] stebo02@sopuli.xyz 15 points 1 year ago
[–] bloodfoot@programming.dev 7 points 1 year ago* (last edited 1 year ago) (1 children)

And if you’re male.

Edit: FFS does no one realize that women experience sex differently from men? Bad sex with an oblivious partner can be downright painful for a woman. The same is typically not true for men. My point was not that women don’t have sex or that they don’t enjoy sex. My point is that they don’t experience it the same way as men.

[–] dylanTheDeveloper@lemmy.world 3 points 1 year ago (1 children)
[–] SasquatchBanana@lemmy.world 5 points 1 year ago (2 children)
[–] Sternout@feddit.de 2 points 1 year ago (1 children)
[–] 10EXP@sh.itjust.works 3 points 1 year ago (1 children)

None of us exist. Does that settle it?

[–] JonEFive@midwest.social 0 points 1 year ago

We're all NPC's in some grand simulation running on a server in a warehouse long forgotten about and abandoned by the gods.

[–] XpeeN@sopuli.xyz 2 points 1 year ago

!womenarentreal@lemmy.world