JavaScript and MVC, Why When and How?
We talked previously about the JavaScriptMVC Framework - a really good JavaScript Framework project to keep an eye on. Since MVC now became a "default" feature in most web frameworks, it was interesting to explore its usage in JavaScript, Ajax, and web 2.0. The MVC pattern is mostly used in web application development to separate between design and logic and make development easier and highly maintainable in enterprise environments. Since JavaScript is excessively used in enterprise today, how could we make it better with design patterns ?
Jonathan Snook wrote an interesting introduction to MVC usage in JavaScript where he applied Model-View-Controller pattern on form validation. It's probably very complex to use in small application, but if you are writing large JavaScriupt-based application this could be with big benefits. Jonathan pointed also to other JavaScript MVC frameworks in addition to JavaScriptMVC : SproutCore and TrimJunction.
Like anything else in development, you’ll have to decide if the trade-off of this kind of separation is worth it. For small applications where you only have a few functions, this type of separation is surely overkill. The larger your application gets, though, the more it benefits from the separating code into Model, View, and Controller.
Would you use MVC in your JavaScript web application ?











AJAX Magazine's RSS
