From: Brandon M. <bnd...@ho...> - 2000-12-12 16:26:26
|
> -----Original Message----- > From: Pascal Bestebroer > Sent: Tuesday, December 12, 2000 3:01 AM > To: dyn...@li... > Subject: RE: [Dynapi-Dev] Inheritance > > > The whole prototype code is THE way that Javascript does inheriting (read > the Netscape references) The problem we are facing is something we did our > selves, in the constructor we should only SET the properties, not create > properties or methods, that causes problems. > Ya can't set properties if you don't first create them... And specifying of properties is usually done in a constructor. BUT, there's no point in calling the superclass's constructor if you already have the values set in the prototype. Right.. so if we are trying to code any sort of inheritance, then we must first make sure we are doing it correctly before we make a monster. The API wasn't originally coded to do what you are doing... it was originally coded to do exactly what I suggested: loop through the prototype object and copy each instance.. (See Dan's original DynAPI 2 release with the widgetinterface object) Ok.. so he was trying to implement some sort of inheritance... it worked, but had a few problems that could have been worked out. So, we go with the built-in prototype inheritance... We must then think of a standard way that DynLayers, or ANY object that will be used as an ancestor for inheritance, to be defined, and instanciated, without breaking any of the other rules of inheritance, or causing any other anomolies. We seem to be focused in fitting this well rounded API into an oval inheritance hole. (Prototype inheritance isn't a well rounded method of inheritance). It just won't fit in it's current state. So... if people still want to use inheritance why not just take a few steps back, and take a good look at how the API is put together and integrated with the other parts. Then spin an altered structure which allows simple, stable inheritance without memory leaks, or anomolies. It's not going to get done unless someone just does it. I have my way, Pascal has his, and you guys have yours. > This also means that the oncreate eventlistener is not correct, I think we > should restate the oncreate method of an object, because that > makes it work correctly in multy-chain inheriting. All inheritance should be done BEFORE any instances are created.. if we do the inheritance each time an instance is created.. there would be a performance hit. Why not get that over with at the begining. Or not do inheritance at all. >See my latest preview release of > dynacore, the image button inherites from the button which > inherits from the > dynLayer which inherits from the DynObject.. that's multi chain inheriting > with events and everything working correctly. > > The only problem, as Robert pointed out, is the unassigned > element with the > wrong ID, this is the only thing I have to get out but the problem exists > because we are creating a new array-element in the constructor.. which > should not be done. > > Note that this problem only exists because we overwrite the ID value in > later object constructors. > > > > Pascal Bestebroer > pb...@oi... > http://www.oibv.com > |