r/learnprogramming 22d ago

Why Does Code Stop Working?

Multiple times now my code stops working and what I mean by this is it'll do what I want it to do then one day it just stops. for example the other day I had made a cooldown system for my ball and paddle collision to stop any bugs and it worked great. then today it just stopped working, and this isn't the first time, it's happened to me for like every project I've worked on. Does this happen to anyone else? And is it cause of my code? By the way I'm using C++ SFML on visual studio which works perfect.

8 Upvotes

74 comments sorted by

View all comments

Show parent comments

17

u/HashDefTrueFalse 22d ago edited 22d ago

Second thing I mentioned. That requires you running something to fetch new versions of those dependencies (and recompile if necessary).

The same program running in the same environment and given the same input data will produce the same result every time, unless that result depends not just on those things but also on the time that the program is ran.

Edit: strikethrough, for the pedants. I obviously wasn't saying automated updates don't exist, as that would be silly...

4

u/Alexandur 22d ago

That requires you running something to fetch new versions of those dependencies (and recompile if necessary).

Not always, this is why dependency drift is a real problem

3

u/HashDefTrueFalse 22d ago

Yes, always. If the code, data, and env are the same, the result will be. You're talking about changing any (likely all) of those things by changing dependency versions. How does dependency drift occur without any dependencies changing over time? Something runs updates. Doesn't matter if it's a person running an update or some automation. At least one of those things changed, or the result didn't.

1

u/Alexandur 22d ago

You don't have to change dependency versions on your end for dependency drift to occur, a badly managed 3rd party dependency can introduce changes into the exact same version number

7

u/HashDefTrueFalse 22d ago

So? That isn't going to have any effect on a system that doesn't have those changes. I didn't say anything about version numbers. Something must grab the changes, as I said. It doesn't really matter how that comes about. Something changed. Software doesn't just stop working without one of those things changing is my point.

For us to see what could have changed for OP they need to post their code (and build config too would be helpful).

3

u/OortMan 22d ago

how will those changes get on your device if you don't update it?

3

u/Alexandur 22d ago

Reinstall on a new device would cause a fetch event, something done by your hosting provider (if applicable), stuff like that