Talking about JSON at the Boulder JUG
I'll give a presentation about JSON at the Boulder JUG tonight. I'll introduce JSON to the audience, talk about consuming and producing JSON, discuss some of the security implications around JSON before talking about some recent developments. This is an extension of the presentation I gave to the Denver JUG a few months ago.
Technorati Tags: richweb
Enjoying The Rich Web Experience
I am now in California. It should be sunny, but I can hardly tell since I'm engrossed into the most excellent Rich Web Experience conference put together by the No Fluff, Just Stuff team.
The focus of this conference is on building rich internet based applications, whether they are written in pure HTML + CSS + JavaScript, Flex, AIR or Silverlight. There are discussions around security, performance, design sprinkled around talks about frameworks.
Access to the speakers is amazing just like any NFJS events. I had conversations with Greg Wilkins (Jetty), Dean H. Saxe (Security) and the usual suspect: Scott Davis, David Geary and Neal Ford. I even indulged in a little bit of hero worship by meeting Douglas Crockford, Yahoo's JavaScript architect. He gave talks on JavaScript and JSON in addition to giving a keynote speech.
The conference itself is a fast paced mix of keynotes, expert panels, presentations and networking. The caliber of the presenters and attendees is quite impressive. This is definitively my type of crowd. Where else would you be discussing and arguing about the meaning of HTTP response codes, the merits of Prototype versus Yahoo! UI Toolkit or Paranoids at Yahoo!? Right here at the Rich Web Experience in San Jose.
Sometimes you are the river...
After my last attempt, I decided that it was very advantageous to me and my team to be able to augment DOM elements with functions that I wish was in the DOM APIs. So I started looking around to see how it was done and looked at the Prototype sources that are shipped with every single Rails project.
Now, Prototype is much maligned for it's interference with the DOM. To work around IE, they simply redefine the Element object and replace it with their own. This does cause problems when other frameworks are sharing the global object with Prototype. The big advantage though is that it allows Prototype to provide functions that are extremely useful, even if they aren't officially part of the DOM.
At this point, I don't plan to simply highjack the Element object, but I can certainly add methods to any returned element. This works under both IE and Firefox (to my great relief). I borrowed Prototype's $ function and are now using my own version instead of document.getElementById. This gives me the chance to intercept finding the element and to add the methods that I want or need on the fly. It's not quite elegant, and it does require a lot of code to be changed in order to take advantage of the new function. It's certainly worth a try though.
Bending the DOM to your will
Update: I thought I was very clever and posted this before testing fully on IE... Problem is that IE doesn't implement the DOM objects as native JavaScript objects. As a result, you can't simply add methods to their prototypes. I'll keep looking for a solution though.
One of the biggest frustration around JavaScript development is the incompatibilities between different browsers. Internet Explorer is certainly one of the biggest culprit in that area with their not quite complete DOM implementation.
A good example is the Option constructor that is available on Firefox and other well behaved browser. It's an extremely convenient alternative to using the core DOM to build drop down boxes. It just didn't seem to be available on Internet Explorer. I therefore had 2 options:
- Do without. Use the raw DOM API or an innerHTML hack to build the options and add them to the drop down box.
- Implement it in my library so it would be available.
I chose option 2. I now check for the existence of the Option constructor and define it if it's not available.
Another example are areas where the DOM API haven't specified a method to remove all children of a node. It's easy enough to do with some looping, but it does get annoying to have to continually rewrite the code. One of the advantages of JavaScript is that the objects are never closed. This includes their prototype. As a result, I added a removeAllChildren function to the Node's prototype. I can now clean up portions of the DOM tree very effectively now.
JavaScript is a very powerful language, and you do not have to submit yourself to the limitations imposed on you by incomplete API implementations. You can always add what you need and bend the DOM to your will.
Learning more about Javascript
Yahoo! is making a few classes on Javascript available through their YUI Theater blog. The classes are given by Douglas Crockford, who is Yahoo!'s Javascript Architect. I took sometime this evening to go through the "Javascript Programming Language" presentation and learned a great deal about the language, which is going to be directly applicable to the work that I am currently doing at TransZap. I would recommend this presentation to anyone who is going to do extensive work using Javascript, which is essentially anyone doing Ajax or Web 2.0 work.
