I know, at least with Netscape(Mozilla), the javascript engines now support setters and getters, so that you can use this.w=xx and it would be able to call a function to set or retrieve the variable. This doesn't help with efficiency, and I don't know how well it is supported in other browsers, but it might be an interesting thing to look at.
Dan Willemsen (If I find a like referencing setters and getters/their support, i'll send another email) On Thu, 2003-03-06 at 16:55, Raymond Irving wrote: > --- Benoit Marchant <[EMAIL PROTECTED]> wrote: > > Well, I would keep it. A problem I see in dynapi3 is > > that the naming > > conventions of the setter methods and their instance > > variables isn't > > consistent. It makes it harder to remember things, > > particularly the > > width and height. The instance variable are w and h, > > but the methods > > are setWidth/getWidth, so many time I found myself > > using alayer.width. > > I guess it's much more efficient in javascript to do > > this.w = 0, the > > this.setWidth(0), right ? > > It's best to avoid writin to the properties of the > objects. Please use the available functions when > setting variables. Using the function setWidth() will > perform certain checks on the w argument to ensure > smooth running of the object. when reading values I > could also suggested that you do the same. For > example: > > the setCursor('hand') will cause a pointer to be > displayed in ie, ns6+, and opera 7+. If you were to > use lyr._cursor='hand' it will only work in ie but not > in ns6,etc. Then same goes for getCursor(). If you > were to use cur=lyr._cursor in ns6 after calling > setCursor('hand') the value returned will be 'pointer' > > > > >Which means that for > > performance reasons we > > are (unfortunately) strongly encouraged to call as > > less function as > > possible ? > > > > Apart from the fact that it makes using the api a > > little more > > difficult, it makes it harder to automate setting a > > value by a > > dictionary that will be used by a function, like the > > html property. The > > method is setHTML, and the property is html. If they > > were following a > > consistent naming convention like > > > > property -> html > > setter -> setHtml > > > > Then we could do something like the following: > > > > DynObject.prototype.takeValuesFromDictionary = > > function(values) { > > > > for(var key in values) { > > /* This would be a workaround when you want to call > > a function without > > relying of an existing naming convention: ex > > aLayer.takeValuesFromDictionary({setHTML:'test'}); > > if(typeof(this[key]) == "function") { > > this[key](values[key]); > > } > > else { > > */ > > var setterName = 'set'+ > > key.charAt(0).toUpperCase(); + > > key.slice(1); > > if(this[setterName] && > > typeof(this[setterName] == > > "function")) { > > this[setterName](values[key]); > > } > > else > > > > this[key] = values[key]; > > //} > > } > > } > > > > So the idea is that you first test if an setter > > exists for this key, > > and if it does, use it, otherwise affect the > > instance variable directly. > > The big win is on ease of use, and compact code, > > which means less to > > download. > > > > Related to this, I wonder what would be the > > performance of using the > > watch method on properties that need additional code > > when set, like > > html ? It would greatly reduce the use of functions. > > Does anyone have > > tried this from a performance point of view ? > > > > Benoit > > > > On Thursday, March 6, 2003, at 12:20 PM, Raymond > > Irving wrote: > > > > > > > > So would you suggest that we keep both methods or > > just > > > used the original method? > > > > > > Any other comments? > > > > > > -- > > > Raymond Irving > > > > > > --- Benoit Marchant <[EMAIL PROTECTED]> wrote: > > >> I ran the 2 versions in IE on the mac, creating > > 2000 > > >> layers with > > >> speedtest.dynlayer-basic.html. And it looks like > > the > > >> regular method is > > >> faster, but not all the time. I don't get > > consistent > > >> results each time. > > >> > > >> Benoit > > >> > > >> On Wednesday, March 5, 2003, at 09:20 AM, > > Raymond > > >> Irving wrote: > > >> > > >>> Hello, > > >>> > > >>> Benoit had originally suggested that we use a > > >>> dictionary object (hash table) to pass > > parameters > > >> to > > >>> DynLayers but that proved must slower than using > > >>> html,x,y,w,h,color. 9I think I've found a way to > > >> let > > >>> the two co-exist: > > >>> > > >>> Old way - The original and fastest creation > > >> method: > > >>> > > >>> DynLayer(html,x,y,w,h,bgcolor) > > >>> > > >>> New ways - slower but more flexible creation > > >> methods: > > >>> > > >>> DynLayer({html:'Hello',x:100,y:100}); > > >>> DynLayer({zIndex:2,w:100,h:100}); > > >>> DynLayer({textSelectable:true}); > > >>> > > >> > > > > > > DynLayer({anchor:{top:0,bottom:0},textSelectable:true}); > > >>> DynLayer({textSelectable:false,html:'Cool!'}); > > >>> DynLayer({x:100,y:100,w:10,h:10,visible:false}); > > >>> > > >>> inline layer - when id is set x,y,w,h,bgcolor,z > > >> and > > >>> html will be replaced with values from inline > > div: > > >>> > > >>> DynLayer({id:'myinline'}); > > >>> DynLayer({id:'boxer',anchor:{left:0:right:0}}); > > >>> > > >>> Optional arguments: > > >>> x,y,w,h,html,bgColor,zIndex,textSelectable, > > >>> anchor,visible,id > > >>> > > >>> > > >>> Changes are inside the attached dynlayer_ie.js > > >> file. > > >>> Please perform all the speed test and > > improvements > > >> you > > >>> can to see if the new creation method makes any > > >> sense > > >>> at all. > > >>> > > >>> > > >>> -- > > >>> Raymond Irving > > >>> > > >>> > > >>> > > >>> > > __________________________________________________ > > >>> Do you Yahoo!? > > >>> Yahoo! Tax Center - forms, calculators, tips, > > more > > >>> http://taxes.yahoo.com/ > > >>> > > >>> > > __________________________________________________ > > >>> Do you Yahoo!? > > >>> Yahoo! Tax Center - forms, calculators, tips, > > more > > >>> http://taxes.yahoo.com/<dynlayer_ie.zip> > > >> > > > > > > > > > __________________________________________________ > > > Do you Yahoo!? > > > Yahoo! Tax Center - forms, calculators, tips, more > > > http://taxes.yahoo.com/ > > > > > > > > > > > > ------------------------------------------------------- > > > This SF.net email is sponsored by: Etnus, makers > > of TotalView, The > > > debugger > > > for complex code. Debugging C/C++ programs can > > leave you feeling lost > > > and > > > disoriented. TotalView can help you find your way. > > Available on major > > > UNIX > > > and Linux platforms. Try it free. www.etnus.com > > > _______________________________________________ > > > === message truncated === > > > __________________________________________________ > Do you Yahoo!? > Yahoo! Tax Center - forms, calculators, tips, more > http://taxes.yahoo.com/ > > > ------------------------------------------------------- > This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger > for complex code. Debugging C/C++ programs can leave you feeling lost and > disoriented. TotalView can help you find your way. Available on major UNIX > and Linux platforms. Try it free. www.etnus.com > _______________________________________________ > Dynapi-Dev mailing list > [EMAIL PROTECTED] > http://www.mail-archive.com/[EMAIL PROTECTED]/ -- Dan Willemsen <[EMAIL PROTECTED]> ------------------------------------------------------- This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger for complex code. Debugging C/C++ programs can leave you feeling lost and disoriented. TotalView can help you find your way. Available on major UNIX and Linux platforms. Try it free. www.etnus.com _______________________________________________ Dynapi-Dev mailing list [EMAIL PROTECTED] http://www.mail-archive.com/[EMAIL PROTECTED]/