quite alright.. I've burned quite a few brain cells of my own over the years.. :-) ----- Original Message ----- From: "Laszlo Teglas" <[EMAIL PROTECTED]> To: "Dynapi-Dev@lists. sourceforge. net" <[EMAIL PROTECTED]> Sent: Monday, December 03, 2001 12:22 PM Subject: RE: [Dynapi-Dev] prototype coding standard
> Never mind. Brain Freeze. Must be all those festive parties lately. I must > have lost a few brain cells on the weekend. > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED]]On Behalf Of Doug Melvin > Sent: December 3, 2001 11:50 AM > To: Laszlo Teglas; Dynapi-Dev@lists. sourceforge. net > Subject: Re: [Dynapi-Dev] prototype coding standard > > > But you make the decision once, only once. > Only on declaring the object definition. > After that, the decision is NOT made again. > The other way, you make the decision every time you execute the code. > > ----- Original Message ----- > From: "Laszlo Teglas" <[EMAIL PROTECTED]> > To: "Dynapi-Dev@lists. sourceforge. net" <[EMAIL PROTECTED]> > Sent: Monday, December 03, 2001 11:48 AM > Subject: RE: [Dynapi-Dev] prototype coding standard > > > > If you have: > > > > if (is.**) { > > DynLayer.prototype._setX=function(){ > > //code to execute > > }; > > } else { > > DynLayer.prototype._setX=function(){ > > //code to execute > > }; > > }; > > > > you are making one decision before you get to the executing code. > > > > If on the other hand you have: > > > > DynLayer.prototype._setX=function(){ > > if (is.ns) { > > //code to execute > > } > > else{ > > //code to execute > > } > > } > > > > you are still making one decision before you get to the executing code. > What > > am I missing here? Did someone do testing that one is faster than the > other > > for drag events? > > > > NanoFace =;^) > > > > > > -----Original Message----- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED]]On Behalf Of Doug Melvin > > Sent: December 3, 2001 10:29 AM > > To: Laszlo Teglas; Dynapi-Dev@lists. sourceforge. net > > Subject: Re: [Dynapi-Dev] prototype coding standard > > > > > > Here's my understanding FWIW: > > If the function will contain code that is common to multiple cases.. > > > > Such as DynLayer.prototype.specificCreate where there mare browser > specific > > cases but the last bit of code is common to all browsers.. then we branch > > inside of the function.. > > > > But if the function will execute fully unique code for each browser then > you > > would branch the declaration itself.. > > > > Ie; to prevent the code from having to domake any more decision than > > nessesary.. > > > > In an Event-Driven environment such as this (this _IS_ an event driven > > enviroment believe it or not) > > A single function can find itself being called a hundred times in a couple > > of seconds (ie; the mouseover event functions for dragging) > > In a case such as this, the fewer decisions(less code) is preferable. > > > > > > ----- Original Message ----- > > From: "Laszlo Teglas" <[EMAIL PROTECTED]> > > To: "Dynapi-Dev@lists. sourceforge. net" > <[EMAIL PROTECTED]> > > Sent: Monday, December 03, 2001 10:18 AM > > Subject: [Dynapi-Dev] prototype coding standard > > > > > > > I was roaming through the core files. > > > > > > And noticed that in most cases we start a prototype declaration first > and > > > then branch off for the various browsers. However in some cases we are > > first > > > branching off and then declaring the prototype functions for each of the > > > browsers. > > > > > > I can see why we would do this if we did not want a prototype for all > > > browsers thus we don't need an else {} block like is the case for: > > > if (is.def) { > > > DynLayer.prototype.getOuterHTML()=function(){ > > > .... > > > } > > > }else if (is.ns4){ > > > DynLayer.prototype.getOuterHTML()=function(){ > > > .... > > > } > > > } > > > > > > But why would we do this for prototype functions where we are > prototyping > > > for all brouwsers with an else{} block, as is the case in: > > > > > > if (is.ns) { > > > DynLayer.prototype._setX=function(){ this.css.left=this.x; }; > > > DynLayer.prototype._setY=function(){ this.css.top=this.y; }; > > > } else { > > > DynLayer.prototype._setX=function(){ this.css.pixelLeft=this.x; }; > > > DynLayer.prototype._setY=function(){ this.css.pixelTop=this.y; }; > > > }; > > > > > > Would it not be better style to write: > > > > > > DynLayer.prototype._setX=function(){ > > > if (is.ns) {this.css.left=this.x;} > > > else{this.css.pixelLeft=this.x;} > > > } > > > DynLayer.prototype._setY=function(){ > > > if (is.ns) {this.css.top=this.y;} > > > else{this.css.pixelTop=this.y;} > > > } > > > > > > Actually you also save a few bytes for all you byte counters. > > > > > > Also for _setHTML, we currently have: > > > > > > if (is.ns4) { > > > DynLayer.prototype._setHTML=function(html) { > > > ... > > > } > > > } else if (is.ie) { > > > DynLayer.prototype._setHTML=function(html) { > > > ... > > > } > > > } else { > > > DynLayer.prototype._setHTML=function(html) { > > > ... > > > } > > > }; > > > > > > Would it not be better to have: > > > > > > DynLayer.prototype._setHTML=function(html) { > > > if (is.ns4) { > > > ... > > > } > > > else if (is.ie) { > > > ... > > > } > > > else { > > > ... > > > } > > > } > > > > > > I think it is better style, and we save two lines of: > > > "DynLayer.prototype._setHTML=function(html)" for all you byte counters. > > > > > > NanoFace =;^) > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > Dynapi-Dev mailing list > > > [EMAIL PROTECTED] > > > http://www.mail-archive.com/dynapi-dev@lists.sourceforge.net/ > > > > > > _______________________________________________ > > Dynapi-Dev mailing list > > [EMAIL PROTECTED] > > http://www.mail-archive.com/dynapi-dev@lists.sourceforge.net/ > > > > > > _______________________________________________ > > Dynapi-Dev mailing list > > [EMAIL PROTECTED] > > http://www.mail-archive.com/dynapi-dev@lists.sourceforge.net/ > > > _______________________________________________ > Dynapi-Dev mailing list > [EMAIL PROTECTED] > http://www.mail-archive.com/dynapi-dev@lists.sourceforge.net/ > > > _______________________________________________ > Dynapi-Dev mailing list > [EMAIL PROTECTED] > http://www.mail-archive.com/dynapi-dev@lists.sourceforge.net/ _______________________________________________ Dynapi-Dev mailing list [EMAIL PROTECTED] http://www.mail-archive.com/dynapi-dev@lists.sourceforge.net/