So i'm looking for "The jQuery Way".. :).
Looking for a consensus on "best practice"/patterns here.
1) Namespaces:
I'm doing MVC namespaces wherein my views have all the "classes" dealing with the traversing of the DOM and element definitions; models contain ajax calls and data binding (?) management (cookies, etc); controller space has an Observer pattern managing events, etc.
2)Constructor - Dynamic Prototyping:
I've had to do some rewriting here. I was doing straight constructors though I read that assigning "methods" to the prototype is more efficient as not doing so recreates the method per instantiation of the "class". My problem is that I liked mocking access in the straight constructor model, wherein I had my local (private) properties and methods
So in order to keep my happy encapsulation and have the memory efficiency of Object.prototype.method, To do this I set a flag at the end of the "class" definition to indicate initialization and use it in a block defining my prototype "methods". Sound right? if that, then, how do I work in the "mock access"? Do I have my getter/setter "methods" in that block I gues? what about the "private methods", I'm guessing those go in there as well, right? (otherwise I'm still clogging up memory with multiple instances of these "methods")
3) Inheritance:
I'm a little at a loss here. I saw some various methodologies to mock this. Deep copy(recursive), object copy, etc. I guess I don't quite understand jQuery's extend(). Does extend copy all properties and "methods" of an object? if so, I'm assuming it does so as well for the .constructor property? I didn't see anywhere that you have to set the constructor property youself thereafter so I'm guessing that it does that by itself, right?
How would you go about mixins? just copy the the objects prototype method?
4) Initialization
Looking over the jQuery core I see:
// The jQuery object is actually just the init constructor 'enhanced'
So what is the best pattern for initialization?
My thanks in advance to those that humor me here. This would help me out not only doing efficient apps as well as contributing safe and reliable plugins and extensions.