Activate your free membership today | Log-in

Wednesday, May 24th, 2006

Prototype Class System

Category: Articles, Prototype

<>p>Dean Edwards came up with Base as a way to give nice inheritence management in JavaScript.

He has tweaked it again.

I’ve made a couple of tweaks to the class since I last blogged about it. The most important change is that I’ve renamed the inherit method to base. I caved in to pressure.

These are the other small changes:

  • added a method to make multiple inheritance (yuk) easier
    JAVASCRIPT:
    1.  
    2. FlyingFish = Fish.extend();
    3. FlyingFish.implement(Bird);
    4.  
  • the Base constructor function can now be used to cast an object to a Base object
    JAVASCRIPT:
    1.  
    2. var widget = document.getElementById("my-widget");
    3. Base(widget);
    4. widget.extend({
    5. ...
    6. });
    7.  
  • constructor functions are now inherited (my bad)

Sam Stephenson of Prototype has started blogging and discussed the issues that he has with current inheritence in Prototype, and how Base could become part of Prototype 2.0.

Related Content:

  • prototype
    In software development, a prototype is a rudimentary working model of a product or information system, usually built for demonstration purposes or as...
  • Prototyping Model
    The prototyping model is a systems development method (SDM) in which a prototype (an early approximation of a final system or product) is built,...
  • EDS enhances virtual design tool
    Electronic Data Systems' (EDS) has announced upgrades to its virtual prototyping product, Vis...
  • Android-based device prototypes displayed
    Android-based prototypes are appearing though actual releases are not expected until the middle of the...
  • spiral model (spiral lifecycle model)
    The spiral model, also known as the spiral lifecycle model, is a systems development method (SDM) used in information technology (IT). This model of...

Posted by Dion Almaer at 9:03 am
4 Comments

++++-
4.5 rating from 26 votes

4 Comments »

Comments feed TrackBack URI

[...] Ajaxian » Prototype Class System (tags: javascript prototype programming inheritance class development Ajax) [...]

Pingback by links for 2006-05-25 at /dev/caffeine — May 24, 2006

Extend/Base is seems wasteful as it’s copied into each object that ‘extends’ from it and does not seem to make good use of the refrence objects/methods, ie prototype (the actual prototype, not the framework)

Comment by Dave — May 30, 2006

@Dave – You are mistaken. Base uses prototype based inheritance.

Comment by Dean Edwards — June 5, 2006

[...] Ajaxian Prototype Class SystemAjaxian Prototype Class System (tags: javascript prototype programming inheritance class development Ajax) [ ] Pingback by links for 2006-05-25 at /dev/caffeine May 24, 2006 [...]

Pingback by Prototype » Prototype Laboratory — July 11, 2006

Leave a comment

You must be logged in to post a comment.