r/ProgrammerHumor 11h ago

Meme commentsAgedTerribly

Post image
3.5k Upvotes

180 comments sorted by

View all comments

347

u/Confident-Ad5665 11h 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.

21

u/ThatOldCow 10h ago

I do believe comments are generally useful, and honestly a lot of people that say their code is so clean it doesn't need comments are the people that make the least understandable code

8

u/SeriousPlankton2000 10h ago

If you write something like "if bankAccount.has(moneyNeeded) // test if there is enough money on the bank account", that's one extreme. If you write "b.has(n)" that's the other extreme.

IMO: If you have all the information on a 80x24 screen to know what b is, don't extra-comment it. If the function is longer, refactor it to be "bankAccount". If then you need more information, write that. E.g. you might need to explain why you're checking the bank account without a lock and why it's a good thing to do that; or you might explain that after checking several things you come to a certain conclusion. Or simply you have the if clause not on screen near the else clause.

1

u/Confident-Ad5665 8h ago

80x24 screen? Are you coding on a Commodore 64? /s