Tarek Ziadé wrote:

Jean-Marc Orliaguet wrote:

Your pattern of creating namespaces using classes creates memory
leaks, I'll post a demo, so you can see for yourself..

you are still mixing concepts here, i am not creating namespaces by
creating classes, i am creating code organized
in classes and use it in my UI. classes organizations reveals therefore
a namespace when it's used.


what I'm saying is that using classes when you could use simple objects has a memory payload. (or maybe the classes are not supposed to be instanciated more than once?) and I'm not sure that I see what it adds compared to how it's done in prototype or in scriptaculous for instance...


This is getting weird, you are going to work on a demo to prove that
this is wrong, over something
that has not be written yet, but 3 lines in a mail + what you thaught
you understood.

well, you reacted first, on the 4 lines that I wrote (that I had copied from scriptaculous), and jumped on the class pattern to create namespaces ... :-)

I simply wrote: "it is possible to create a namespace by creating a simple javascript object" and you wrote: "Hey wait! now we have scriptaculous we can use classes instead to achieve this.."

wait when the guideline will be written,
at least when some of it will be, so we are talking on something
concrete we all understand and see.

[cut]

why do you want to put that in a loop ?
sorry i don't get that point, put a loop over any instanciation and
it consumes memory, yes.
The browser's garbage collector is called when the page is closed or
reloaded. So as long as you run the application on a same page, it is
as if you
were inside a loop. Putting the code inside a loop helps you identify
memory leaks as the ones you have just created.

Yes, but i still don't understand why you want to create more than one
instance here... and why you want to prove that creating a class instance
is a memory leak... there's no crazy loop anywhere but in your mind here ;)


this is exactly what I'm saying since the beginning, if you only need one instance, then you don't need to use Class.create(), you can just as well write:

var MyStuff = {
  ...
}

and extend it with functions, variables, classes. But I don't see why you'd need to define a class to instanciate it only once?

/JM
_______________________________________________
cps-devel mailing list
http://lists.nuxeo.com/mailman/listinfo/cps-devel

Reply via email to