Interfaces in MS Ajax
I'm currently reading MS Ajax in Action book and am enjoying to the fullest. I didn't know how easy it is to declare an Interface in the JavaScript using MS Ajax (even though, the original JavaScript doesn't support Interfaces).
The example (of IComparable Interface from the book) is as follows: (assuming you have correct configuration for MS Ajax on your aspx page)
Samples.Temperature = function(value)
{
this._value = value;
}
Samples.Temperature.prototype =
{
compareTo : function(comparand) {
if(Samples.Temperature.isInstanceOfType(comparand)) {
var thisValue = this.get_value();
var comparandValue = comparand.get_value();
if(thisValue == comparandValue)
return 0;
return (thisValue > comparandValue) ? 1 : -1;
}
else {
throw Error.argumentType();
}
},
get_value : function() {
return this._value;
},
set_value : function(value) {
this._value = value;
}
}
Samples.Temperature.registerClass('Samples.Temperature', null,
Samples.IComparable);
The other JavaScript framework that I always liked, is, jQuery. It's just awesome when you want to do quick animation, drag n' drop, etc. without adding a lot of code.
In future, I'm planning to post more code from my experience with MS Ajax and other Ajax related goodies.