this post was submitted on 06 Jul 2024
845 points (100.0% liked)

Programmer Humor

418 readers
3 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
[–] mundane@feddit.nu 41 points 2 months ago (3 children)

Comments should explain "why", the code already explains "what".

[–] smeg@feddit.uk 38 points 2 months ago* (last edited 2 months ago) (3 children)

The allowable exception is when the what is a what the fuck, as in you had to use a hack so horrible that it requires an apology comment

[–] mundane@feddit.nu 8 points 2 months ago

Absolutely, although I see that as part of why

Why is there a horrible hack here? Because stupid reason...

[–] sukhmel@programming.dev 4 points 2 months ago

Or if the what is so cryptic and esoteric that it would require the reader a couple hours of research to understand it.

Also, I find it useful to summarise the what before code blocks if that can't be summarised in a function name

[–] bleistift2@sopuli.xyz 3 points 2 months ago

Describing the what also helps when you dabble in a new technology or little-used technology. It helps to explain to yourself what you’re doing and it helps in onboarding. “Hey, newbie, there’s a function in XYZ module that’s extensively documented. Look there for guidance.”

[–] azdle@news.idlestate.org 3 points 2 months ago (1 children)

Unless you're working with people who are too smart, then sometimes the code only explains the how. Why did the log processor have thousands of lines about Hilbert Curves? I never could figure it out even after talking with the person that wrote it.

[–] mundane@feddit.nu 1 points 2 months ago* (last edited 2 months ago)

If you know how the code does something, you also know what it does.

load more comments (1 replies)