JS Snippet – Basic module pattern

/* DATA MODULE */
var dataController = (function() { 
    
    // object constructors
    // prototype methods
    return {
      // public data methods    
    };
    
})();

/* UI MODULE */
var UIController = (function() {
    
    // DOM
    return {
      // public DOM manipulation methods
    };
    
})();

/* APP CONTROLLER MODULE 
the appController function accesses the data and 
UI controller public methods
*/

var appController = (function(dataCtrl, UICtrl) {
    
    // Event handlers
    // Call data and UI controller public methods
    
    return {
        init: function() {
            // initialization function;
        }
    };
    
})(dataController, UIController);

// Call to initalization function
appController.init();

JS Snippet – IIFE pattern

/* 
Basic Immediate Invoked Function Expression (IIFE) pattern
*/

// without input parameters
var module = (function() { 
   // code 
})(); 

// with input parameters 
var dataControllerModule = (function() { 
   // code 
})(); 
var UIControllerModule = (function() { 
   // code 
})(); 

var appControllerModule = (function(dataCtrl, UICtrl) { 
   // code 
})(dataControllerModule, UIControllerModule);