Download

Concepts

Example

Documentation

Plugins

How to

Contribute

Links

MVC - Module View Controller

From Wikipedia

Model–view–controller (MVC) is an architectural pattern used in software engineering. Successful use of the pattern isolates business logic from user interface considerations, resulting in an application where it is easier to modify either the visual appearance of the application or the underlying business rules without affecting the other. In MVC, the model represents the information (the data) of the application; the view corresponds to elements of the user interface such as text, checkbox items, and so forth; and the controller manages the communication of data and the business rules used to manipulate the data to and from the model.

Translation

There are three components which consist of the view, the model and the controller. The view is what the user will see, such as button, text, etc. The model contains and manages the datas. The controller manages the communication between the view and the model.

Why MVC is interesting ?

If you are reading this, it is because you are doing a lot of Javascript, probably in a team. If your company is lucky, you probably also have a designer, an HTML integrator and at least one JS developper. You are working all together to build a nice Javascript application.

So you also know reading code written by someone else can be really long and/or hard. What does he want to do in this method/function ? Where does he implement this functionnality ? MVC can help you to find your or someone else's code faster.

The code you are looking for is managing data. It is in the model. It deals with the view. It is in the controller. The designer change some id in the HTML code. You change the controller and it works again. Nice !

Woozoo and MVC

So the framework use this logic. Say you have a button in your HTML file. Once the user clicks on it, the controller will catch the event and pass the information to the model so it can treat the data.

But after you treat that data, you will probably want to update the view. But the model can't communictae directly with the controller or the view. Ouch ! How do you solve this problem ? Use the bindings.