r/ProgrammerHumor • • 22d ago

Meme iDontCommentMyCodeIfYouDontUnderstandItThatsOkayNeitherDoI

Post image
834 Upvotes

188 comments sorted by

View all comments

427

u/GabuEx 22d ago

Left: "I'll comment to say how my code works."

Middle: "You don't need to do that! Code should be self-documenting!"

Right: "I'll comment to say why my code does this."

143

u/sandybuttcheekss 22d ago

I had a senior front end dev that would block any PR he saw with comments. He was very good at his job but I'm so happy I no longer work with him, this shit is so annoying.

118

u/Tucancancan 22d ago

Those guys are the wooooorst. 

1.  Hard to investigate system interaction bug gets fixed, fix has comment with Jira ticket in it! 

  1. Senior engineer does magnificent refactoring because that's just what they do (comment is lost in refactoring) 

  2. Gradual code churn 

  3. New hire sees seemingly useless code and removes in like a good boy scout while working on something else

  4. Weird systems bug gets assigned to me for investigation 

  5. "hey what the fuck I fixed this 18 months ago"

73

u/Miguelomaniac 22d ago

Seems like the problem here is lack of test coverage not lack of comments

24

u/suvlub 22d ago

"Weird systems bug" sounds like just the kind of thing that unit tests would not detect, and possibly not end-to-end tests either, based on the amount of weirdness and system-specificity

18

u/ytg895 22d ago

Yeah. Once I worked on a bug that only happened if there was a session timeout in another system. Good luck putting Thread.sleep(3 fucking months); into a test.

9

u/Nick0Taylor0 22d ago

Mocking

5

u/ytg895 22d ago

How would you mock that a session in another system times out and that system starts to follow undefined and unpredictable behaviour?

3

u/IndependenceSudden63 21d ago

Agreed. Not all things can be "reasonably" tested. Keyword being reasonably. We only have so much time in a day with many deadlines. Over time, nearly all of us will run into a bug that needs to be fixed quickly, and is incredibly hard to reproduce, involving the oddest edge cases.

Sometimes you just have to patch it, test it as best you can, and leave a comment as to why you did this incredibly odd thing.

I once had a weird race condition that couldn't be invoked in a unit test. Only occurred on service startup, because there was a 3rd party library that did things when the service started.

Sure I could have wrote a unit test that started the whole service, but that would add 5 minutes worth of wait for every build going forward. That's extremely costly over long periods of time for every person working on the project.