this post was submitted on 14 Mar 2025
573 points (99.3% liked)

Programmer Humor

21487 readers
1619 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 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] cbazero@programming.dev 14 points 12 hours ago (1 children)

You dont. Thats why you write code that explains itself. For higher level info you write documentation.

[–] Gumbyyy@lemmy.world 6 points 4 hours ago (1 children)
[–] Maalus@lemmy.world 2 points 4 hours ago (1 children)

The only moment you write comments is when you are doing something extremely weird for a specific reason that will not be immediately obvious and you want to warn the person doing a refactor in the future. In any other case, writing self documenting code is the way. If you are unable to do that, then your code needs to be rewrtitten.

[–] ruekk@lemm.ee 5 points 3 hours ago (1 children)

Self documenting code is a myth as what's self documenting to one person is not to the next. Code comments and process/workflow documentation is needed for a healthy codebase.

[–] Maalus@lemmy.world -5 points 3 hours ago (2 children)
[–] ADandHD@lemmy.sdf.org 5 points 2 hours ago (1 children)

♫tale as old as time♫ ♫opinions that are mine♫

[–] Maalus@lemmy.world -1 points 2 hours ago

Not really an opinion when most companies run on self documenting code since time immemorial.

[–] zalgotext@sh.itjust.works 0 points 2 hours ago (1 children)

Try handing over your "self documenting code" to a junior dev who doesn't know the language it's written in and see how far they get with it.

Now hand that exact same codebase with comments to the same junior dev, and I guarantee you they'll get further than without the comments.

[–] Maalus@lemmy.world 1 points 2 hours ago (1 children)

I have given well documented code to plenty of juniors, it comes with being a senior dev / techlead. And it was perfectly understood. Maybe you simply don't write self documenting code.

[–] zalgotext@sh.itjust.works 0 points 52 minutes ago

Lmao. Sure buddy.