ivyprojectsextendindex

Extend

Clean OOP layer for JavaScript

News

Check the latest version of Extend !
→ Extend 2.0 (Oct 2007)
→ Read the documentation

Extend provides a small and flexible OOP-layer on top of JavaScript that allows class-based inheritance and provides a fairly complete reflective API to access class information and class hierarchy from objects.

Features

Class-based inheritance
Extend allows you to easily declare classes, specialize them by inheritance, and clearly define their content. Extend support instance and class attributes as well as instance and class methods.
Full reflectivity and type operations
Any Extend class instance can be queried using getClass() to get class information (object.getClass().getName()). Classic type operations such as isInstance() allow to test an instance against a class.
Rich declarations
Extend allows you to be very explicit when you declare a class and makes the difference between class and instance attributes and methods. You can also name your classes so that you can print more developer-friendly debugging information.
Proper super handling
Most libraries fail at providing a proper way of doing super-related operations, and often have shady semantics in this regard. Extend makes the semantics of the model clear and provides easy ways to do these operations.

Design

Extend is really about provinding a foundation for complex application development with JavaScript. Prototype-based object model is very good for language and framework designers because they give a lot of flexibility, but when a program grows, classes (and the specialization/generalization mechanism) become necessary.

Extend was designed as a class-based object model layer on top of the prototype-based object model, for people willing to do serious developing in JavaScript.

Extend does not depend on any JavaScript library, and can work well with any of the existing JavaScript framework. We use Extend a lot with jQuery, which we really recommend !

Getting started

To start using extend in your applications, simply add the following line to your HTML header:

 <script type="text/javascript" src="http://www.ivy.fr/extend/extend-2.0.js')"></script>

After this, you can start declaring your first class:

var Shape = Extend.Class(
  name:"Shape",
  initialize:function(){
    this.points = [];
  }
  methods:{
    addPoint:function(p){
      this.points.push(p);
    }
    getPoints:function(){
      return this.points;
    }
  }
});

You can the read the documentation, where you will have a complete introduction to how to use Extend.