I'm looking for ideas on improving the structure of modules within a
website. As code grows within a single file (generally representing a
page or module controller), I find it becomes important to organise
the file well. At the moment I have a rather arbitrary set up, based
on the concept of Model/View/Controller:

myModule = function(){
  var Model = {
    // data manipulation stuff goes here. eg:
    parseJSONResponse: function(){}
  };
  var View = {
    // dom stuff goes here
    getInputFieldValue: function(){}
  };
  var Controller = {
    // handling of interesting moments
    bindEvents: function(){},
    init: function(){}
  };
  return {
     init: Controller.init
  };
}();

I find this separation helps people to understand the code. The
consistent format means it's easy to follow the module set up, and it
leans toward writing single-purpose functions.

It is as I mentioned entirely arbitrary and as such not ideal. Can
anyone suggest a simple structure that may improve the situation?

Tom

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to