From: Brandon M. <bnd...@ho...> - 2000-12-12 00:34:37
|
>> Wouldn't it be better to say: >> MyObject.prototype = DynObject.prototype >I guess this would only create a pointer, so that changes to >MyObject.prototype would affect DynObject.prototype Very good point.. so should we then loop through the prototypes?.. Assigning the individual functions, but not the entire prototype? Do this to avoid setting variables or objects which would then be shared by all instances of the subclass. function Label() { this.theLayer=new DynLayer(); } Label.prototype=new DynObject(); Then..... function Button() { this.theLayer.addEventListner(Button.mouseEvents); // More stuff here too. } Button.mouseEvents=...blah blah blah.... Button.prototype=new Label(); // Cause a button is just a label with events. Now.. guess what? All instances of Button will share the same DynLayer reference. Is this what is intended? I don't think so. Now.. don't get on my case that I used Dan's original widget model.. it's just a practical example. Any object in place of the "theLayer" object would have the same problems. -----Original Message----- From: dyn...@li... [mailto:dyn...@li...]On Behalf Of Simon Dicon Montford Sent: Monday, December 11, 2000 6:12 PM To: dyn...@li... Subject: RE: [Dynapi-Dev] Inheritance > I was wondering the point of this line when inheriting objects: > > MyObject.prototype = new DynObject(); It's so that any changes to DynObject.prototype at runtime will be reflected in MyObject.prototype > Wouldn't it be better to say: > MyObject.prototype = DynObject.prototype I guess this would only create a pointer, so that changes to MyObject.prototype would affect DynObject.prototype SD _______________________________________________ Dynapi-Dev mailing list Dyn...@li... http://lists.sourceforge.net/mailman/listinfo/dynapi-dev |