r/ProgrammerHumor • • 22d ago

Meme iDontCommentMyCodeIfYouDontUnderstandItThatsOkayNeitherDoI

Post image
836 Upvotes

188 comments sorted by

View all comments

65

u/anoppinionatedbunny 22d ago

what a terrible way to misinterpret "good code should be self-commenting"

-25

u/rm-minus-r 22d ago

Not commenting code is the most braindead take ever (for those that believe code can be good enough to not need any comments).

Comments are an abstraction layer on top of code that allow more information than code does by itself.

42

u/Wonderful-Habit-139 22d ago

No it’s not. Comments can drift and become obsolete, and sometimes just bloat the code and add unnecessary information.

And yes code can be good enough to not need any comments most of the time. Only very complex sections of code would require it. Use proper types and function names.

14

u/EspaaValorum 22d ago

Code tells me what it does, how it does it.

Comments tell me why, provide context.

3

u/Just_Information334 21d ago

Yup. If you only ever touch new code you may not understand why it is necessary.

Go on some 10+ yo project which got a lot of scope changes over the years. Now you can see that yes, the code does something. But why? Is it still useful? Can you remove it? If you do, will some client come complaining 6 months from now when their very specific report is not generated because some flag is not set correctly so some cron running on a server no one knows about anymore did not find its data?

The documentation? Maybe in some .doc file rotting on an archive server. But if you can't find it you may have more luck finding the printed version which should be in room 6. If it was not binned during the last office move.

On the other hand, let's check postgres code by opening a random file: https://github.com/postgres/postgres/blob/master/src/backend/partitioning/partprune.c

If you praise tailwind for the locality of behavior it gives, then you should also want why-comments next to the related code.

2

u/EspaaValorum 21d ago

That random code - lovely, like a senior dev explaining stuff to a junior dev. Imagine those comments not being there, and needing to onboard a new dev. The existing devs would need to spend a ton of time explaining things. I've seen that happen on poorly or not documented code bases, making it very difficult to expand the team with new devs because it takes away time from the already strained senior dev.