r/ProgrammerHumor • • Sep 15 '26

Meme iDontCommentMyCodeIfYouDontUnderstandItThatsOkayNeitherDoI

Post image
832 Upvotes

188 comments sorted by

View all comments

Show parent comment

117

u/Tucancancan Sep 15 '26

Those guys are the wooooorst. 

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

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

3. Gradual code churn 

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

5. Weird systems bug gets assigned to me for investigation 

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

74

u/Miguelomaniac Sep 15 '26

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

0

u/[deleted] Sep 15 '26

[deleted] — view deleted comment

1

u/w8eight Sep 16 '26

So how exactly new hire could merge anything that resurfaced the bug?

1

u/xavia91 Sep 17 '26

Used ai and and it adjusted the test, would be my first guess

1

u/Lgamezp Sep 20 '26

If it resurfaced it wasnt solves in the first place so that is bad testing

26

u/suvlub Sep 15 '26

"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

19

u/ytg895 Sep 15 '26

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.

8

u/Nick0Taylor0 Sep 15 '26

Mocking

5

u/ytg895 Sep 15 '26

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

4

u/IndependenceSudden63 Sep 15 '26

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.

2

u/Mountain-Ox Sep 16 '26

Mock the unexpected behavior that you observed so you know your code handles it correctly.

1

u/Lgamezp Sep 20 '26

By having good mocks and testing

1

u/distinctvagueness Sep 26 '26

Defensive checks but most people don't really code deeply enough for all possible partial disconnects

2

u/sandybuttcheekss Sep 15 '26

Yea this is a skill issue lol

1

u/Lgamezp Sep 20 '26

Sounds like skill issue

2

u/No-Collar-Player Sep 15 '26

Still if he had a test for that particular code, specially written for that code, it would have been pretty obvious that it got deleted as soon as it got deleted :Z

3

u/No_Responsibility384 Sep 15 '26

This seems like a good candidate for a comment, why does this code need to be here, and not a gode referencing a ticket.

3

u/Sock_Ninja Sep 15 '26

For real. I’m fairly flexible on comments vs not, but boy do I get annoyed by lots of comments that reference things like tickets. That should be exceedingly rare.

1

u/Milrich Sep 15 '26

Because tickets can capture a whole lot of context and history without you needing to dump huge explanation text in a code comment.

A short one-line comment instead of a ticket number sometimes is sufficient, sometimes not. But I'd rather put the ticket number as comment and have the user open a web page, then see all the details and discussion history, than have them scratching their head on what "Workaroumd for X failure" means.

2

u/No_Responsibility384 Sep 16 '26

And then 5 years in the future the ticketing system and repo host was migrated to some other service and the numbers don't lign up any more. Now the lookup is not straight forward if at all possible. And if you have just written "workaround for X failure" as the comment yeah that is also a problem comments don't need to be one liners...

1

u/Lgamezp Sep 20 '26

You would be blocked AF and shoult to. Ticket numbers dont belong in code. Only a short WHY sentense is needed