The code below is for modern browsers only.

Naming conventions are as follows:

m or M - Model

v or V - View

c or C - Controller

     *( C )ontrol
     *  Cin -  Input Path
     *  COut - Ouput Path


    var COut = ( function () 
        var messages = 
            name:         'Please enter a valid name',
            email:        'Please enter a valid email',
            email_s:      'Please enter a valid email.',
            pass:         'Please enter password, 6-40 characters',
            url:          'Please enter a valid url',
            title:        'Please enter a valid title',
            tweet:        'Please enter a valid tweet',
            empty:        'Please complete all fields',
            same:         'Please make emails equal',
            taken:        'Sorry, that email is taken',
            validate:     'Please contact <a class="d" href="mailto:foo@@host.com">support</a> to reset your password'





1 Answer 1


The code within the functions seems clear and simple to me, so my answer mostly focus on the naming conventions:

  1. Why call your variables m..., v..., c... when you could call them "model", "view", "controller"? This would make your code immediately clearer to anyone who reads it.

  2. The functions under "CIn" are also prefixed with "c", which is redundant. Since COut is a controller, it is obvious, that its functions are controller functions so they could simply be called "tryIt", "block", etc.

  3. Strictly speaking, in MVC, the role of a controller is to handle user input and (optionally) to output data. There is not one controller for input and another one for output, both should be handled by the same controller. It might make sense however to wrap output operations in a separate class. In Kohana for instance there's a "Response" object. This is pretty much what you've done with COut, except that you shouldn't call it a controller since that's not really what it is. You could call it "Response" or "Output" for example. "HtmlResponse" might be a good choice too as that would allow you to also have "JsonResponse", "XmlResponse", etc.

  • \$\begingroup\$ - Originally I spelled it out...but MVC is so prevalent + I provided a key \$\endgroup\$
    – user7459
    May 28, 2012 at 16:05
  • \$\begingroup\$ - In the explanations I've seen output is not optional for a Controller class. If you have reference otherwise, please let me know. \$\endgroup\$
    – user7459
    May 28, 2012 at 16:07
  • \$\begingroup\$ - Additionally, I've removed the module patterns as I don't need closure...a simple function object will be more efficient. I will update here in a bit. \$\endgroup\$
    – user7459
    May 28, 2012 at 16:09
  • \$\begingroup\$ - This is the model I'm using betterexplained.com/articles/… \$\endgroup\$
    – user7459
    May 28, 2012 at 16:17
  • \$\begingroup\$ - It shows all data in/out of Controller \$\endgroup\$
    – user7459
    May 28, 2012 at 16:17