I have been having many problems trying to understand what is the best pattern to suite my needs. It seems like, given all the classes i need to write for all my tasks, the module pattern is less likely to work because it runs at runtime function(){}(), therefore if i had all my 30 tasks all written with the () after them, they would all run every time a page is loaded. I am not sure why this matter isn't discussed more, in fact i try to use the module pattern only for really small things that i use all over the place, otherwise I just keep myself bounded to this idea:
var namespace = {};
namespace.Classname = function() {
// constructor
function privateFunction() {
// private
}
this.privilegedFunction = function() {
// privileged
privateFunction();
};
};
namespace.Classname.prototype = {
aMethod: function() {
this.privilegedFunction();
}
,anotherMethod: function(){}
}
var class = new namespace.Classname();
I feel like this pattern is what globally suites my development style.