Model Viewer Controller (MVC) is a software architecture,currently considered an architectural pattern used in software engineering. The pattern isolates "domain logic" (the application logic for the user) from input and presentation (UI), permitting independent development, testing and maintenance of each.For instance, you may refer to "controller" as "input", "model" as "processor" or "processing" and "view" as "output".
So in other words, controller receives input passes it to the model for processing, or to the view for output. SO MVC benefits include :
1. Isolation of Business Logic from the user interface.
2. Ease of keeping code DRY.
3. Making it clear where different types of ode belong for easier maintenance.
Lets explain each in detail mentioning each functionalities.
1) MODEL
A model represents the information (data) of the application and the rules to manipulate that data.Models are primarily used for managing the rules of interaction with a corresponding database table. In most cases, one table in your database will correspond to one model in your application. The bulk of your application’s business logic will be concentrated in the models.
2) VIEW
The view renders the model into a form suitable for interaction, typically a user interface element. Multiple views can exist for a single model for different purposes. A viewport typically has a one to one correspondence with a display surface and knows how to render to it.
3) CONTROLLER
The controller receives input and initiates a response by making calls on model objects. A controller accepts input from the user and instructs the model and viewport to perform actions based on that input.
So the steps involved in the working of MVC is as follows :
So in other words, controller receives input passes it to the model for processing, or to the view for output. SO MVC benefits include :
1. Isolation of Business Logic from the user interface.
2. Ease of keeping code DRY.
3. Making it clear where different types of ode belong for easier maintenance.
Lets explain each in detail mentioning each functionalities.
1) MODEL
A model represents the information (data) of the application and the rules to manipulate that data.Models are primarily used for managing the rules of interaction with a corresponding database table. In most cases, one table in your database will correspond to one model in your application. The bulk of your application’s business logic will be concentrated in the models.
2) VIEW
The view renders the model into a form suitable for interaction, typically a user interface element. Multiple views can exist for a single model for different purposes. A viewport typically has a one to one correspondence with a display surface and knows how to render to it.
3) CONTROLLER
The controller receives input and initiates a response by making calls on model objects. A controller accepts input from the user and instructs the model and viewport to perform actions based on that input.
So the steps involved in the working of MVC is as follows :
- The browser makes a request, such as http://learnwithnitin.blogspot.in/2013/12/powerful-vi-editor.html
- Webserver receives the request. It uses routes to find out which controller to use. The webserver then uses the dispatcher to create a new controller, call the action and passes the parameters.
- Controller do the work of parsing user-requests, data submissions, cookies, sessions and the browser stuff. Controller asks the model to get data from database and will eventually display it to user.
- Models are classes. They talk to the database, store and validate data, perform the business logic. It retrieves data from the database.
- Views are what the user sees : HTML, CSS, XML, Javascript, JSON.Views are merelu puppets reading what the controller gives them. They don't know what exactly happening in the background.
- The controller returns the response body (HTML, XML etc) and metadata (caching headers, redirects) to the server. The server combines the raw data into proper HTTP response and sends it to the user.
No comments:
Post a Comment