Please see below:

--- Benoit Marchant <[EMAIL PROTECTED]> wrote:
> I would prefer
> I  prefer the syntax super.setSize(w,h).
> 
> What about adding
> 
> DynAPIObject.prototype.overwrite = function(sC,n) {
>      var c = this.frame[sC];
>      var superMethod =
> c.prototype._superPrototype[n];
>      var capitalized = n.charAt(0).toUpperCase() + 
> n.substring(1,n.length);
>      var      superMethodOverridename = 'super'+
> capitalized;
>      if(superMethod &&
> !c.prototype[superMethodOverridename]) {
>          c.prototype[superMethodOverridename] =
> superMethod;
>      }
> };
> 
> and in the class you want to overwrite:
> p.setSize = function(width,height) {
>       this.superSetSize (widt h,height);
>       //Then do your stuff
> }
> dynapi.overwrite('EventObject','setSize');//which
> basically does 
> p.superSetSize = mySuperClass.prototype.setSize
> 
> 
> that way it's in the same fashin as the
> setPrototype() ?
> It's "clean" in the sense that it's important to
> overrides only the 
> implementation defined is in your super class,
> guaranteeing a correct 
> overriding if different subclasses overrides the
> same method multiple 
> time. In javascript, it's easy to directly  get the
> implementation of 
> an of your ascendant, and bypass some !
> 

Looks good. One question though... How  would this
work with multiple overrides?

example:

function MyClass1(){}
var p= dynapi.setPrototype('MyClass1','DynLayer');
dynapi.overwrite('MyClass1','setSize');
p.setSize=function(w,h){
  this.superSetSize(w,h);
   // code here
};

function MyClass2(){}
var p= dynapi.setPrototype('MyClass2','MyClass1');
dynapi.overwrite('MyClass2','setSize');
p.setSize=function(w,h){
  this.superSetSize(w,h); 
  // will the above superSetSize be DynLayer's or
MyClass1 setSize function?
  // If it's MyClass1 then how will the MyClass1 code
access DynLayer's setSize()?

   // code here
};

Also, how will it work with multiple extensions?

example:

// extension library #1
dynapi.overwrite('DynLayer','setSize');
DynLayer.prototype.setSize=function(w,h){
   this.superSetSize(w,h);
  // code here
};

// extension library #2 - loaded after extension #1
dynapi.overwrite('DynLayer','setSize');
DynLayer.prototype.setSize=function(w,h){
   this.superSetSize(w,h);
  // code here
};

When setSize id called will it execute code in the
following order?

object -> extension #2 setSize() -> extension #1
setSize() -  DynLayer's orginal setSize()

> > Is the term "subclass" correct or should we term
> it as
> > "overwrite"?
> We should use overwrite, it's the appropriate term
> in OO terminology 
> when a subclass modify an inherited method.

Thanks

--
Raymond Irving

> 
> Benoit
> 
> >
> > Any comments?
> >
> > --
> > Raymond Irving
> >
> > __________________________________________________
> > Do you Yahoo!?
> > Yahoo! Tax Center - File online, calculators,
> forms, and more
> > http://tax.yahoo.com
> >
> >
> >
>
-------------------------------------------------------
> > This SF.net email is sponsored by: ValueWeb:
> > Dedicated Hosting for just $79/mo with 500 GB of
> bandwidth!
> > No other company gives more support or power for
> your dedicated server
> >
>
http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
> > _______________________________________________
> > Dynapi-Dev mailing list
> > [EMAIL PROTECTED]
> >
>
http://www.mail-archive.com/[EMAIL PROTECTED]/
> >
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com


-------------------------------------------------------
This SF.net email is sponsored by: ValueWeb: 
Dedicated Hosting for just $79/mo with 500 GB of bandwidth! 
No other company gives more support or power for your dedicated server
http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
_______________________________________________
Dynapi-Dev mailing list
[EMAIL PROTECTED]
http://www.mail-archive.com/[EMAIL PROTECTED]/

Reply via email to