Are you a fan of object-oriented programming, and you wish you could make elegant, readable javascript classes? Magic Classes could be what you're looking for. There are a number of javascript files out there that provide similar functionality, and I'm not claiming that this is revolutionary. The goal of Magic Classes is simply to provide a very simple interface for classes, namespaces, and inheritance in Javascript.
Magic Classes is an open-source library released under the New BSD license. You can find the source code at its Google Code project page. Most of the inheritance code comes from an older version of the Ext JS library, back when it was LGPL and allowed its code to be shared by all.
Declaring a namespace that's 3 levels deep:
com.magicClasses.GetNamespace('com.adamia.math');
Defining a new base class with a constructor:
com.adamia.math.Class( 'Vector2D', {
x : 0
, y: 0
, construct : function() {
this.x = 1;
this.y = 1;
}
});
Extending another class:
com.adamia.math.Class( 'Vector3D', 'Vector2D', {
z: 0
, construct : function() {
com.adamia.math.Vector3D.superclass.constructor.call(this);
this.z = 1;
}
});
It's a pretty simple library, and I welcome (constructive) feedback for ways to improve it.
Comments
Buy cheap Links of London
Buy cheap Links of London jewellery at online jewellerybarnd UK store, including Links of London Necklaces, Links of London Charms, Links of London Earrings, links of london links london Hundreds of links of london jewellery in stock,Free Gift Wrapping, links of london Necklaces links of london Rings links of london Earrings Complete links of london jewellery collection,including necklaces,bracelets,earrings links of london Bracelets links of london Charms links london Sweetie Bracelets Best Discounted UK Tiffany Jewellery Sale Outlet provides designer Tiffany Ring, necklaces and other jewelry in wholesale price. UK Tiffany specializes in Tiffany jewellery Tiffany
Thanks for these OOP
Thanks for these OOP tutorials. I am searching all over the internet for these free tutorials, at last I win. Your blog is great and full of interesting information. Search for different new gadgets is my hobby. This is my favourite topic. For one reason I am a good searcher and that reason is professionally I am a Ethical search marketing manager and in these days I am working on my new project called gundog scurries and this is totally based on java script. I need little help so that I gain from Magic classes. Thanks once again.
I think this would be
I think this would be remarkable, bringing OOP to JavaScript is not taught in any of the exams like EX0-101 nor is it part of the traditional 70-646 exam so finding pros with such abilities should be harder and worth a lot of good.
Post new comment