It's Never One Loose Screw
It’s Monday morning and your client has discovered a bug in their application. Of course, you didn’t write the buggy code, but the fix looks simple. So, you promise you can have it fixed right away. Sound familiar?
If you ever find yourself thinking the solution to the bug is obvious, chances are you’ve not yet thought about how all of the parts of the system interact.
Let me tell you a story about a recent morning of mine dealing with a “bug”.
One benefit of working at MojoTech is that they provide all employees with UpDesks, which can switch between sitting and standing positions using a manual crank. As I cranked my new desk up to the standing position, it seemed like some of the screws holding the desk surface to the leg structure were a bit loose. When the desk was in its final position, it had an infuriatingly subtle jiggle. With the help of my new neighbor, I flipped the desk upside down to inspect the situation, quietly guessing I knew the required fix.
It appeared that the bracket that served as the interface between the wood and the metal leg structure was not fully secured. Tightening these screws, however, would require I remove a total of 12 wood screws first. It would take a little more time than I first guessed, but once I had access to the surface screws, my problem would be fixed.
After revealing the set of screws that held the bracket to the legs, it was clear that these were the source of the problem and needed tightening. With some effort, I managed to tighten each of these screws about a quarter turn.
Satisfied, I thought to myself, “that ought to do it.”
But, upon further inspection, I realized that the metal bracket was held against the metal of the leg structure without any sort of washer between them. All of the screws I could see were tight, but the desk still had a jiggle.
To increase the friction between legs and bracket, I decided to fold a small piece of paper and use that as a washer between the metal surfaces. I carefully placed my fix and tightened down the screws.
“Success,” I thought to myself.
But the bracket to leg interface was now rock solid, revealing that the next set of screws in the leg structure was also loose! Even worse, there was no way to access those screws in order to tighten them.
Defeated, I slowly screwed the remaining bracket in, placed the entire structure on the desk surface and began the punishing process of tightening those 12 wood screws by hand. After flipping the desk back upright, I moved it back into place against the wall. As I did so, I realized that if I pushed it tight against the wall, there was no room for the structure to wiggle at all!
What I thought to be an obvious loose screw turned out to be a much deeper problem. In the end, the best solution was the simplest and did not even involve the assumed culprit. Changing that one line of code will often reveal other parts of your program that need to be adjusted. It’s rarely as simple as tightening one screw.