Best thing about all this studying and learning gaining confidence in myself and my skills because:
More knowledge != falling for bad code || bad instructions || bad tutorials
I learn, among other things, to trust myself. It doesn’t always feel that warm and fuzzy, however.
Sometimes the problem is something completely unpredictable and beyond your control. Some bizarre unforeseen factor you’d never ever have guessed. You spend hours changing Code Block A, then changing it back; changing Code Block B (and changing it back), wondering if Code Block B v2 would work if you’d kept Code Block Av2 so you try that until you are confused, exasperated, and exhausted only to find, say, the text editor you’ve been using updated itself automatically in the middle of the night and the new version adds some secret, previously non-existent “thing” rendering moot all of your efforts during the last 48 hours because you haven’t been selecting the new “rumpelstiltskin” radio button in the “Publish Settings” tab of the “Save As” dialog box when saving your file. You didn’t know that existed because you’ve just been pressing Ctrl+S (this is all a thinly veiled reference to Adobe Flash CC).
Even a 48-hour stretch of debugging can end with dignity and new knowledge but cases like the above leave you feeling bitter and violated. After that happens a couple times, you’ve got a rare case of PTSD unique to coders. You’ll always wonder if any extended period of debugging are actually completely futile and the gods are laughing at you.
Sometimes, when the most recent change makes it all finally work you don’t jump up, pump your fists and shout “eureka” because you’re sitting there feeling empty thinking, “But I KNOW I tried that several times already.”
It All Started With
A different image should appear in the masthead each time the page is loaded. Simple. My randomImage function would include:
- myImages = An array of images
- randomNumber = a random number generator
I didn’t even need to look up or learn anything so I thought I’d try something cool. I wanted each page in the site to have it’s own array of images so I created a separate js file with multiple arrays and wrote my function to take an argument which I’d call in each web page like:
and so on.
It didn’t work. So I did the first thing I always do: I second-guessed myself and began changing code in which I’d previously had perfect confidence. Since everything seemed correct it could be anything that was, in fact, incorrect.
Was it the id? Where I’d placed the link to the external js file? My function? Which line in the function? The code for the array? Was it because I was testing locally? Without a webserver (I wasn’t using my own computer)? The browser I was using (I only had access to IE)?
So I broke down and simplified the function, just tried an embedded script, anything to isolate and identify the problem. I didn’t care how stupid it would make me feel as long as I could complete this task and move on.
When you’re constantly thinking, “This is SO simple. I’m going to solve this any second now.” HOURS fly by.
As It Turns Out (the next day)
It was just something at work. The IT Nazis must have something in place that regularly prevents any of my code from working. Even simple, local code.
As It Really Turns Out (a few days later)
I based that last paragraph on the fact that everything worked fine at home on my iMac and laptop but … FACEPALM … I had, um, well, the images in the wrong, you know, folder.