This post refers to DotKernel 1, based on Zend Framework 1.
If you are looking for DotKernel 3 related posts, go here.

MVC is a design pattern used in software engineering, especially in the field of user interface programming. The MVC paradigm is a way of splitting an application, or even just a piece of an application’s interface, into three parts: the model, the view and the controller.
 

The model encapsulates the business logic and business data of an application. It is used to obtain all necessary application data from the database. The model corresponds to enterprise data and business rules that lead access to and updates of this data. The MVC goal is to make the model independent from the view and the controller.
The view renders the contents of a model. It receives data from the model and displays it to the user. The view represents the User Interface (UI).
The controller converts the user’s interactions with the view into actions that the model will process. In an enterprise web application, they are the GET and POST HTTP requests. Depending on the conditions, a controller may also select a new view, to display back to the user.

 
Model View Controller
 
Here are some short principles to understand better MVC:

Model

– actual content, usually stored in a database or XML file;
– must be independent, it can’t refer to either the view or the controller portions of the application; may not hold direct instance variables that refer to the view or the controller;
– should hold methods that manipulate the data.
– Should NEVER generate output directly

View

any code necessary to generate your display
– obtains data from the model and presents it to the user
– reads data from the model using query methods provided by the model
– should not change the state of the model
– can communicate with the model but communication should be read-only
– returns the User Interface

Controller

– receives requests from the user, calls methods from the model(manipulate data) and the view(returns response to the user – usually HTML)
– Controlling Logic
– Pulls it all together
– Instantiates Models
– Causes Models to do something
– Hands the results of the model’s action to the view
– Renders the view
– Handles exceptions
– is NOT a mediator between the model and the view .

DotKernel team encourage the idea of “Fat Models, Skinny Controllers”.



Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>