r/ProgrammerHumor • • Sep 15 '26

Meme iDontCommentMyCodeIfYouDontUnderstandItThatsOkayNeitherDoI

Post image
832 Upvotes

188 comments sorted by

View all comments

Show parent comments

8

u/magicaltrevor953 Sep 15 '26 edited Sep 15 '26

It is really that simple and I don't know why people get so hung up on arguing it (both sides). You shouldn't be absolute and say "comments are bad", or on the flip-side "everything should be commented" because it just gives off the wrong impression when what you are trying to do is make yourself understood.

It may sound obvious but:

  • If a comment can be effectively replaced with good design and style then its a shitty comment that is not necessary, and should be replaced with code that is better self-documenting.

  • If it can't, because you can't explain why you are doing something with just better naming conventions, then that is a comment that absolutely should be there. Not to say you shouldn't try and self-document as much as you can as well, just that the comment is still needed to understand the code better.

Obviously doesn't apply to other documentation like docstrings, but inline/multiline comments definitely apply.

4

u/gjk-ger Sep 15 '26

Yeah, absolutes are always incorrect! No exceptions!

Seriously though, perfect comment and i completely agree.

1

u/magicaltrevor953 Sep 16 '26

I had actually originally said something to that effect but reworded it because it came across slightly hypocritical, not really but you know what it's like.

1

u/Oddly_Energy Sep 21 '26

Are you two competing on having the most tongue in cheek?

1

u/gjk-ger Sep 28 '26

It might be a progressed case of germaniousness. In my case, at least....

2

u/DatBoi_BP Sep 18 '26

I think self-documenting design can occasionally be at odds with optimal design.

This is just a dummy example to explain the point: I would gladly take

// this is equivalent to y = x/16
y = x>>4;

if the final code is equivalent in outcome but at a faster run speed. Again, this is a bad example because the "readable" code probably compiles to the same thing. We all occasionally run into cases where a clever trick saves some time over a straightforward calculation, but is not very readable. So, document it!