Helma Logo
main list history
previous version  overview  next version

Version 4 by hannes on 28. July 2006, 11:33

A few days ago, I came across Dean Edward's *Base Class for JavaScript Inheritance|http://dean.edwards.name/weblog/2006/03/base/*. I liked the general idea of adding syntactic sugar to JavaScript class-like inheritance. However, I think some things could be improved:

* the code of the Base class is pretty unreadable, because it tries to do too much in too little space
* methods in parent prototypes are called as this.base(), which looks nice but is far from self-explanatory and easily clashes with application methods or properties
* the this.base property is set before each method call, and reset to its previous value afterwards. This isn't very elegant or efficient, and it doesn't deal with exceptions that might be thrown
* extending of priviledged methods is problematic. each constructor in the proto chain that gets called will create its own scope with its own private members and priviledged methods. Overriding priviledged methods will operate result in those methods operating on a entirely different set of private variables, leading very likely to unexpected results.

I'll describe my solution in an update to this page. For now, here's the code:

<% this.attachments %>