I'm interested in using the Module Pattern to better organize my future projects. Unfortunately, there are only a few brief tutorials and proof-of-concept examples of the Module Pattern.
Using the module pattern, I would like to organize projects into this sort of structure:
project.arm.object.method();
Where "project" is my global project name, "arm" is a sub-section or branch of the project, "object" is an individual object, and so on to the methods and properties.
However, I'm not sure how I should be declaring and organizing multiple "arms" and "objects" under "project".
var project = window.project || {};
project.arm = project.arm || {};
project.arm.object = (function() {
var privateVar = "Private contents.";
function privateMethod() {
alert(privateVar);
}
return {
method: privateMethod
};
}());
Are there any best practices or conventions when defining a complex module structure? Should I just declare a new arm/object underneath the last?