Friday, March 27, 2009

Something about MVC (Model View Controller)!!!

I heard so much about MVC and want to share some basic things about MVC.
Basically MVC is a design pattern defined many years back and ASP.NET MVC Framework is the framework to implement MVC pattern.
As Per wordPress the defination of MVC Pattern is
“Model–View–Controller (MVC) is an architectural pattern used in software engineering. Successful use of the pattern isolates business logic fromuser 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.”
Now lets understand MVC Framework.

MVC is a framework methodology that divides an application’s implementation into three component roles: models, views, and controllers.
· “Models” in a MVC based application are the components of the application that are responsible for maintaining state. Often this state is persisted inside a database (for example: we might have a Product class that is used to represent order data from the Products table inside SQL).
· “Views” in a MVC based application are the components responsible for displaying the application’s user interface. Typically this UI is created off of the model data (for example: we might create an Product “Edit” view that surfaces textboxes, dropdowns and checkboxes based on the current state of a Product object).
· “Controllers” in a MVC based application are the components responsible for handling end user interaction, manipulating the model, and ultimately choosing a view to render to display UI. In a MVC application the view is only about displaying information - it is the controller that handles and responds to user input and interaction.
One of the benefits of using a MVC methodology is that it helps enforce a clean separation of concerns between the models, views and controllers within an application. Maintaining a clean separation of concerns makes the testing of applications much easier, since the contract between different application components are more clearly defined and articulated.
The MVC pattern can also help enable red/green test driven development (TDD) - where you implement automated unit tests, which define and verify the requirements of new code, first before you actually write the code itself.

Some benefits of MVC are :
Clear separation of concerns
Testability - support for Test-Driven Development
Fine-grained control over HTML and JavaScript
Intuitive URLs
I will try to post more and more things about MVC.

No comments: