707
you are viewing a single comment's thread
view the rest of the comments
[-] magic_lobster_party@kbin.social 9 points 1 year ago

Comments should only be used to describe stuff that’s otherwise difficult to convey with code.

[-] xmunk@sh.itjust.works 18 points 1 year ago

The best explanation I've ever heard is:

Comments should state the 'Why' never the 'What'.

[-] hikaru755@feddit.de 1 points 1 year ago

There are some cases though where the code is just complicated for reasons outside of your control, in which case "what" comments are good - but they should never be taken at face value, but only used as a first step in understanding the code. There's a significant risk of the code not actually doing what the comment says.

[-] dukk@programming.dev 3 points 1 year ago

Yeah. Most of the time I use comments in my algorithms, as they often use some weird optimized black magic which are difficult to understand without comments.

[-] DoomBot5@lemmy.world 1 points 1 year ago

Like don't set this value to the obvious default. Bad stuff happens

this post was submitted on 24 Oct 2023
707 points (97.7% liked)

Programmer Humor

19623 readers
1 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