Archive for the ‘JavaScript’ Category

Bing API PHP Wrapper Re-factoring

Thursday, January 14th, 2010

A few months ago I released Bing API PHP to the public out of boredom, it was a hobby, still is. Now re-visiting my code I discovered a few things that needed to be introduced. Starting with an Abstract class, mostly all of Bing’s XML responses are almost equal to each other. Except for some cases, yet, in the midst of working on a solution on how to “write less” and “be more efficient gathering data”. I totally forgot about abstract classes, not just totally forgot, the next version of the wrapper itself got stalled due to attempting to “write less”.

Why did I start re-factoring now? Good question! It had something to do with OpenType Threads, working on my prototype has taught me a lot of things about classes, design patterns and a better problem solving skill. So when I looked at my wrapper class, I said to myself “hmmm… maybe we should do this one more time”. Yet, while this is still a hobby, one of my goal of why to re-factor the code was to allow me a better manipulation with JavaScript. I know I can use XML in JavaScript but well, we’ll see how it goes :)

So it’s time to pay a visit to Bing’s API documentation and delete old code without thinking twice.

1 people like this post.

JavaScript Madness?

Tuesday, January 12th, 2010

I’ve been learning JavaScript for a few days now. Yesterday I got stuck and tried to find documentation, to my disappointment there isn’t a “centralized documentation” of the JavaScript language, it’s methods or useful examples. It’s more about experimenting and just listen what your guts tell you. Some have linked me to JavaScript’s model specifications giving me interfaces and what it should return (and so on) others linked me to MDC ( Microsoft Mozilla Development Center ), MDC has nailed it, very easy to understand examples, brief overview of the JavaScript technology and its Data Types, objects constructs and literals (literals has left me quite with a “wow”).

All nice, right? MDC seems like a nice resourceful spot (of course!), now this story will take a plot twist, and it starts when I test my JavaScript code in Internet Explorer, IE yelled errors with nonsense. I took a deep breath, lets do the math! Mozilla: Gecko, Google Chrome: WebKit, IE: well I think it was called “Trident”, and Opera? god knows, I forgot. So these people have different implementations on how to render the web, great! Now, they also have a different way on how to interpret JavaScript, just great! The Internet Explorer team needed to follow Microsoft’s standard, that is, just tweak a few things and claim it. (Like addEventListener converted to attachEvent, extra code is great :) god bless JavaScript libraries for this)

I cried myself to sleep yesterday. I just had one thought in my mind, “why it had to be like this, how about uniting or something… a centralized documentation, SOMETHING!”. I guess that won’t happen, like a fleeting dream :(

Don’t get me wrong, I like some of Microsoft technology (and their C# language). I also secretly like their Bing Search Engine, don’t tell anyone ;)

I’d like to thank Justin Johnson for his great help over StackOverflow, enlightened me :)