This is very much of a chicken or the egg situation. But there is much of a correlation with my approach to problem-solving that I use in both life and technical problems and troubleshooting.
Let me preface it with, it took me a while to learn this lesson when I was in elementary and junior high but everybody knows that I do not do hardware. I just don’t fuck with it. Even if it’s just a bad hard drive? Nope. One of the attributes that lead me to fall in love with software is that it is resilient. You can sit there and try and fix software or a bug in your code all day every day and usually you can’t break something that will actually cost money versus tearing up a motherboard and not having the money to replace it, as well as an angry family for tearing up the family computer.
While writing code, most of your time gets spent on mundane lines just setting up the application. Ex. Connect to the database server, validate the user, grab the user preferences, blah blah blah. Necessary but not particularly difficult after you’ve been doing it for several years. Then you start writing a process you have never written or in a different way. It never works on the first attempt. Ever. More often than not, most of your code is correct. There’s usually just something small you overlooked. You forgot to increment a variable in a loop. You forgot to end a statement with a semi-colon. You forgot to include a file. Whatever the problem, you stop the program, go back to your code and start glancing over the code you wrote. Sometimes the bug is immediately apparent and you correct the issue, test it and move on. Other times, the problem isn’t immediately apparent so you start debugging. Anyone who has experience debugging, what you don’t want to do is go back and completely rewrite everything. If you do, you then have to try to figure out which change fixed the actual problem. Instead, you go back to your code, study it, change one thing, test, if it works, great! If it doesn’t work, go back, undo the change you made and change something else. And repeat until you get the desired result.
Isn’t this how life works?
The longer you spend doing anything the more mundane code you have memorized. Code that you’ve written a thousand times before and have confidence in. Then once we encounter a new problem, we don’t come back and throw everything away, given that most of it are irrelevant to the current problem. We come back, change one small detail and try again until we get the result. And before we know it, this current problem is just in the pile of the code we know that works and we are off to debugging the next problem.