title: Javascript module pattern: When to go private with methods? Getters/setters? Room for improvement?
body: <p>I'm working with a pattern that looks like so (pseudo example):</p>
  
  <pre><code>var FOO = (function(foo) {
  
      var foo = foo || {},
      setThis = 'someValue';
  
      //--------------------------------------------------------------------------
      //
      // Public methods:
      //
      //--------------------------------------------------------------------------
  
      foo.init = function(bar) {
  
          this.blah = [];
  
          // Constructor stuff here...
  
      };
  
      foo.doSomething = function(bar) {
  
          if (bar) {
  
              this.doSomethingElse();
  
              // Stuff here...
  
          }
  
      };
  
      foo.doSomethingElse = function() {
  
          // Stuff here...
  
      };
  
      //--------------------------------------------------------------------------
      //
      // Private methods:
      //
      //--------------------------------------------------------------------------
  
      foo._imPrivate = function() {
  
          // ... stuff here ...
  
          this.blah = xyz; // References this.
  
      };
  
      foo._morePrivate = function(el) {
  
          // No reference to this.
  
      };
  
      foo._otherPrivate = function(el) {
  
          // No reference to this.
  
      };
  
      return foo; // Expose the methods.
  
  }(FOO || {}));
  </code></pre>
  
  <p>Instanciated like so:</p>
  
  <pre><code>window.onload = function() { FOO.init(stuff); }
  </code></pre>
  
  <p>Three questions:</p>
  
  <ol>
  <li>If my "private" methods don't reference <code>this</code>, should I just make them "standard" functions (i.e. <code>function _imPrivate() { ... }</code>, for example)? <strong>Reason why I ask:</strong> I have a few methods that reference <code>this</code>, but I don't want to give them public access; I also have a few "utility" methods that don't reference <code>this</code>... Can the methods that reference <code>this</code> be standard functions (in context of the module pattern)?</li>
  <li>Could someone provide an example of how I would implement a setter for the <code>setThis</code> variable?</li>
  <li>Do you see any room for improvements in the above code?</li>
  </ol>