Hi,

Prototype.js is going through some troubled times with class-based
inheritance. A few days ago I mentioned my suggested solution of using
Kevin Lindsay's eight line extend function to solve these problems.

http://kevlindev.com/tutorials/javascript/inheritance/index.htm

I've blogged about how this tiny extend function gives us so much
important Ruby-like behavior. Below are three examples showing both
Ruby and JavaScript versions of each.

http://peter.michaux.ca/articles/2006/06/02/class-based-inheritance-in-javascript

http://peter.michaux.ca/articles/2006/07/24/ruby-open-classes-and-inheritance-in-javascript

http://peter.michaux.ca/articles/2006/07/24/ruby-module-remove-method-in-javascript

You will see that this approach to class-based inheritance in
JavaScript is very clean and powerful and dramatically reduces the
amount of code needed to set up classes and inheritance compared with
Prototype.js 1.5's approach. This approach also enables the open-class
concept as shown in the second and third examples which is not
possible with the current Object.extend function.

Peter
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to