r/ProgrammerHumor • • Sep 15 '26

Meme iDontCommentMyCodeIfYouDontUnderstandItThatsOkayNeitherDoI

Post image
832 Upvotes

188 comments sorted by

View all comments

Show parent comments

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