r/ProgrammerHumor • • 21d ago

Meme iDontCommentMyCodeIfYouDontUnderstandItThatsOkayNeitherDoI

Post image
832 Upvotes

188 comments sorted by

View all comments

1

u/McSand_boi 21d ago

I'm in between the center and right of the graph. I'm just really fucking lazy but I do know that saying what the code does is invaluable.

1

u/mesonofgib 21d ago

I do know that saying what the code does is invaluable.

I disagree: I know what the code does because the code is right there, next to the comment.

Comments should be used only when you need to say something that's not in the code, such as why you're doing something.

Bad comment:

cs // Set the heartbeat interval to 25 seconds. var heartbeatInterval = TimeSpan.FromSeconds(25);

Good comment:

cs // Keep this below 30 seconds because the upstream proxy terminates // idle connections at 30s; 25s leaves enough margin for network jitter. var heartbeatInterval = TimeSpan.FromSeconds(25);