this post was submitted on 05 Jun 2025
220 points (97.8% liked)

Programmer Humor

24912 readers
1491 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
[–] Quetzalcutlass@lemmy.world 5 points 1 month ago (14 children)

Except those imports were used by a huge section of code you temporarily commented out, and now you'll need to manually select a dozen imports to get it working again when you come back to it.

(Sure you could have just commented out the unused imports, but the linter auto-sorted them and you're feeling too lazy to copy-paste a dozen scattered lines)

[–] blaue_Fledermaus@mstdn.io 32 points 1 month ago (1 children)

That is what version control is for.

[–] entropicdrift@lemmy.sdf.org 22 points 1 month ago (2 children)

This. Commenting out code is bad practice

[–] naeap@sopuli.xyz 2 points 1 month ago (1 children)

In general, I'm with you
But sometimes I need to revert/comment out a code block, because another code part isn't finished/working as it should.
Sure, it clutters code, but if I just comment out a function call and temporarily replace it with the workaround, it should imho stay in code.

Else the workaround will stay forever and the commented out code will act as a reminder, that this part isn't clean yet.

But maybe it really is a case by case thing, where sometimes it's better to branch it out for later merge - although that can get really messy, while having the future implementation commented out, others will also see, how it is supposed to work and don't try to further extend the workaround, which makes future merging hell

Out of interest, how would your best practice look in such cases?

[–] entropicdrift@lemmy.sdf.org 4 points 1 month ago* (last edited 1 month ago)

I would make it a TODO so that it's clearly temporary and so the linter bugs me about it until the intended permanent code is restored.

In general I prefer to keep separate branches and maybe a draft PR open for visibility for that kind of situation, though.

[–] ulterno@programming.dev 1 points 1 month ago* (last edited 1 month ago)

Yeah, I stopped using comments as a code ON/OFF switch when I started using git.
But then I handed over my project to someone without OCD and now the repo is full of code inside comments.


And because I don't use git stash properly enough, in some projects, my stash is 3+ stacks long, with almost the same changes in each of the stashed entries.

load more comments (12 replies)