title: How do I group similar methods and variables together in an object oriented approach?
body: <p>I'm looking for standard way to do this..
  This post <a href="https://stackoverflow.com/questions/8043611/how-do-i-consolidate-methods-into-objectsexcellent-in-progress">here</a> explores 3 ways. <a href="https://stackoverflow.com/questions/8045897/should-i-consolidate-similar-methods-into-javascript-objectsassociative-arrays">Here</a> to.  Which way should you use for a generic case...is it a matter of preference.<br>
  For example if I use the instantiation way..than I have two lines of code instead of one...I have to instanitate the object...and than call the method...
  If I use a static type implementation than I don't have to instantiate any objects.
  The 3rd option the module pattern...is more costly b.c. it is self-executing.</p>
  
  <p>If I had to name them:</p>
  
  <ol>
  <li>object - non static</li>
  <li>object - static</li>
  <li>module pattern</li>
  </ol>
  
  <p>Which way is suggested in general so I don't have to debate this each time I begin to consolidate methods.</p>
  
  <p>Here is an example of collected methods I would like to consolidate.</p>
  
  <pre><code>/********************
  group:checks
  ********************/
  
  var patterns = 
    {
    name: /^[a-zA-Z-\s]{1,20}$/,
    email: /^[a-zA-Z0-9._(-)]+@[a-zA-Z0-9.(-)]+\.[a-zA-Z]{1,4}$/,
    pass: /.{6,40}/,
    url:  /^[(-)\w&amp;:\/\.=\?,#+]{1,}$/,
    aml:  /&lt;(.+)_([a-z]){1}&gt;$/
    };
  
  /*
  - check_generic() - generic 
  */
  
  function check_generic(reg_ex_in,text,html_id,response)
    {
    if(!reg_ex_in.exec(text.value))
      {
      fill_id(html_id,response);
      return 0;
      }
    return 1;
    }
  
  /*
  - check_empty() - checks for empty text 
  */
  
  function check_empty(text,html_id,response) 
    {
    for(var a=0;a&lt;text.length;a++)
      {
      if(text[a].value==='')
        {
        fill_id(html_id,response);
        return 0;
        }
      }
    return 1;
    }
  
  /*
  - check_same() - checks if two text entries are the same 
  */
  
  function check_same(text1,text2,html_id,response)
    {
    if((text1.value)!==(text2.value))
      {
      fill_id(html_id,response);return 0;
      }
    fill_id(html_id,'');
    return 1;
    }
  </code></pre>