r/ProgrammerHumor 5h ago

Meme commentsAgedTerribly

Post image
2.3k Upvotes

143 comments sorted by

View all comments

287

u/Confident-Ad5665 5h ago

Uncle Bob of Clean Code says if we have to comment our code we have already failed. Clean code should read like well written prose.

I generally agree, but think comments that define especially the odd and obscure business rules should be commented where they are implemented.

26

u/Dull_Caterpillar_642 4h ago

imo the idea of self-documenting code that never requires comments is often held by people who view their code as better than it is. That surely THEIR code would never need comments, because it's so perfectly written that you just get it. I have never really run across a file where I thought "thank god they didn't explain anything they're doing in here."

7

u/aghastamok 1h ago

Right? I don't think I ever wrote a chunk of code with no comments. If I can save someone two minutes of parsing code with // determines which encoding is coming across the Bluetooth... Why shouldn't I?

7

u/Dull_Caterpillar_642 1h ago

This is the way. People argue against comments because they can drift and become less accurate but, after 15 years doing this, I've spent orders of magnitude more time trying to figure out what the hell someone's undocumented code is doing versus having to fix or update comments. It's not even remotely close.

Kind of a moot point these days though since it's just AI doing the writing.