Tutorials to .com

Tutorials to .com » Website » Ajax » Anonymous Classes in JavaScript and the XMLHttpRequest API

Anonymous Classes in JavaScript and the XMLHttpRequest API

Print View , by: iSee ,Total views: 9 ,Word Count: 191 ,Date: Wed, 26 Aug 2009 Time: 10:07 PM

Todd Ditchendorf has written up his thoughts on JavaScript, and API usage.

He discusses the XmlHttpRequest API, and some of its ugliness, and gets into the way popular wrappers of the API work a la:

var client = new BetterHttpClientAPI (); client.addListener ((id: 123, responseReceived: function (evt) (....), otherHelperMethod: function () (....)));

javascript is a prototype-based OO language, and I find that it is best to NOT try to make it look like a class based one, so the idea of having a JavaScript "object" which has properties, some of which are functions, is a natural way to design an API.

This isn't exactly anonymous inner classes, as that isn't the way JavaScript works.

As we see more and more people jump into JavaScript I think we need to do a better job on selling the prototype system, and not try to think of class based languages that we may also use and try to fit JavaScript into that world:)

Ajax Tutorial Articles

Can't Find What You're Looking For?

Rating: 5.0


No comments posted.