MVC and it’s siblings have been around for a while and developers are comfortable bathing in the warm light of their maturity and wide-spread advocation. However, a few years ago developers started doing more of their coding client-side and as a natural consequence the lines between M, V and C became blurred leaving many of us cold and uncomfortable when trying to explain where the architectural puzzle pieces belong.
I’m sure you’ve had a similar experience. Anyone who’s used jQuery, for example, has been in the uncomfortable situation where controller code now exists within view and even worse these two are tightly coupled by virtue of jQuery selectors. To make matters more complicated if you’ve ever used class-names for application state or .data() then you’re model, view and controller are now more tightly bound than the figures in a Kamasutra carving.
This is not a new problem but the solution(s) are quite new to me and so I thought I’d share my experiences.
jQuery is Great. But…
Anyone who knows me or my work is familiar with my evangelism of the framework, and it still has it’s place, but times are a-changing and we-the-developers need different tools now. jQuery is a DOM-manipulation framework, the best in the world but to be effective in the development of web applications we need new architecture tools.
MVC in a traditional sense is split across the tiers of client- and server-side infrastructure. However a number of new paradigms and tools exist that firmly embed another layer of MVC (or MVP/MVVM/etc.) within this traditional setup. Over the past few months I’ve done some investigation to determine the value of such tools and I have been blown away. Some of the frameworks that I’ve looked at are:
This is list is not exhaustive and neither are these tools exactly the same in what they deliver but the overlap is sufficiently significant to consider them the “same”.
I invite you to dig deeper into these tools yourself but in a nutshell they typically are:
- use either MVC or MVVM as their architectural base
- are loosely coupled within their operational paradigms i.e. controller and models are independent
- use ORM to represent data
- serialise/deserialise the data objects to/from JSON
- are loosely coupled with the view
- can be combined with jQuery
That is all
In a later post I’ll detail the creation of an app to demonstrate the ease and power of these new frameworks through the use of KnockoutJS. Currently I’m building applications using Knockout since it’s easy to learn, incredibly elegant and famous of being concise. For those of you that would like a sneak peek the source code is here, and there’s a demo here.