MVC is a framework for building web application using MVC (Model View Controller) design.
Model
- The Model represents the application core (for instance a list of database record).
View
- The view displays the data (the database record).
Controller
- The Controller handles the input (to the database records).
The Model:
The model is the part of the application that handle the logic for the application data.
The View:
The View is the part of the application that handle the display of the data. most often the view are create from the model data.
The Controller:
The controller is the part of the application that handle user interaction.
Let's See an Example:
Suppose we're developing an online book store. The user can perform actions such as: view books, register, buy, add items to current order, create or delete books (if he is an administrator, etc.). Let's see what happens when the user clicks on the fantasy category to view the titles we have available.
We will have a particular controller to handle all books-related actions (view, edit, create, etc). Let's call it books_controller.php for this example. We will also have a model, for example book_model.php, handling data and logic related to the items in the shop. Finally we will have a series of views to present, for example, a list of books, a page to edit books, etc.
What are the Advantages?
The most obicous advantage we gain using MVC is a clear separation of presentation (the interface with the user) and application logic.
To be Continuous.
No comments:
Post a Comment