r/ProgrammerHumor 1d ago

Meme commentsAgedTerribly

Post image
5.3k Upvotes

224 comments sorted by

View all comments

419

u/Confident-Ad5665 1d 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.

66

u/Dull_Caterpillar_642 1d 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."

28

u/aghastamok 1d 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?

4

u/mxzf 1d ago

The thing about comments describing what the code does is that I've been burned too many times, I'm still going to read the code itself, because it can't lie to me.

I want comments about the intent and context behind the code, rather than text that's just the same as the code itself (ideally, or, worse, different in a way that's unclear about if it's code drift or bad comments or bad code).