ashleysheridan.co.uk

Welcome

If this is your first visit, you may want to look towards my portfolio and CV, where you will find information about me, and some of my work. The portfolio will be updated regularly as I work on newer projects.

Contained in the articles section you will see an assortment of articles directed from personal opinion, across a variety of subject areas. If you have any feedback or suggestions on any of the articles, please contact me.

Change To The Front Page

I've made a slight amendment to this front page of the site. It will now show my last blog entry. See the main blog section to view all previous entries.

Debugging is a major part when writing software in any language, and Javascript is no exception. Sometimes though, even the most simple of code can create problems, and even fly in the face of logic and reality. Any of you who have read any of the Discword books by Terry Pratchett will understand exactly what I mean when I say I had a Hex moment.

The code itself was a simple function that was the receiver for some XML after an AJAX call. Now, almost all of the function was working correctly, and I was able to fully process the XML object which was returned. The final part of my function was meant to adjust some classes on a couple of div objects, just for aesthetic reasons. This last part however, was the one which didn't work. After a while of cursing, and staring, I realised that I was referencing variables which were not in my immediate scope. "No problem", I thought, "I'll just comment this if/else statement out and come back to it later." At least, that was the plan. No sooner had I commented out the if/else, than the whole function ceased to, well, function.

This was bizzare, as the only properties I was setting were class names of HTML tags, which weren't read anywhere else by any Javascript except this very if/else! I commented ut the lines inside the logic one at a time, just to catch the offending line, and had no results at all, not even when I'd commented out each and every line that wasn't part of the if statement. So, here I have one function with an empty if/else, which, as it's empty, can't do a single thing, yet when I remove it, the whole thing ceases to work properly. My situation was exactly that of Ponder Stibbons, who was able to discern no purpose to the mouse nest, yet when it was removed from Hex, it stopped, just like my function.

Eventually, I did solve it, but only by re-writing the function under a different name. I've no idea what happened, but I'm worried that if I look at it again too closely it might realise and break again!

November 2008
SMTWTFS
1
2345678
9101112131415
16171819202122
23242526272829
30