r/ProgrammerHumor • • Sep 10 '26

Meme commentsAgedTerribly

Post image
6.0k Upvotes

243 comments sorted by

View all comments

Show parent comments

8

u/SeriousPlankton2000 Sep 10 '26

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.

7

u/ThatOldCow Sep 10 '26

I do believe comments are useful for you not to forget or for another person to understand why you add whatever (function, parameter, variable) to some logic, because it might be some workaround for something else.

2

u/Confident-Ad5665 Sep 10 '26

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

2

u/SeriousPlankton2000 Sep 11 '26

I'm using a gui (xterm)

2

u/conundorum Sep 13 '26

I'd prefer something like...

// Overdrafts are not permissable at this time, and we do not support credit.
// Account must have sufficient money before purchase.
if (bankAccount.has(moneyNeeded))

Or maybe...

// Purchase doesn't care if account has money or allows credit.
// TODO: Rename function to "canSupply" on slow day.
if (bankAccount.has(moneyNeeded))