HTML and CSS Reference
In-Depth Information
JavaScript MVC Frameworks and the Server
With the myriad of JavaScript MV* (aka MVC) frameworks popping up over the past
few years, it's important to get a high-level view of what frameworks are available today
and how they support some form of server-side interaction.
In theory, JavaScript frameworks offer developers an easy path to organizing code. After
a few years of attempting to manually organize AJAX/jQuery callbacks, the development
community recognized the need to create frameworks around frontend code. Devel‐
opers realized that complex client-side applications do not scale with spaghetti code and
that keeping up with manually bound, AJAX-returned data using innerHTML() can get
quite messy. So the solution was to use variations of a pattern known as MVC ( Model-
View-Controller ). MVC separates the concerns in an application down into three parts:
• Models
• Views
• Controllers
Although JavaScript MVC frameworks help us structure our code, they don't always
strictly follow the classic pattern shown in Figure 4-8 . Some frameworks will include
the responsibility of the controller in the view such as Backbone.js , while others add their
own opinionated components into the mix, as they feel this is more effective.
Figure 4-8. The MVC process
For this reason, I refer to such frameworks as following the MV* pattern; that is, you're
likely to have a view and a model, but more likely to have something else also included.
If your goal is to learn the basics of each MV* framework on the market today, TodoMVC
( Figure 4-9 ) provides implementations of a to-do app in more frameworks than anyone
has time to learn. Currently there are around 40 JavaScript MV* frameworks in exis‐
tence. Choosing the right framework for a given project is the start of your journey.
Search WWH ::

Custom Search