The MVC an acronym for Model-View-Control is a cross platform design Pattern in software development. This is a software architectural design for implementing user interfaces for desktop and web browsers.The MVC design pattern presents a tectonic shift from the traditional approach of Input Process Output to Controller Model View approach. All the popular platforms of development like .NET, PHP, Java, facilitate use of MVC architecture.
In the traditional web form based software development approach a single program file contains UI (User Interface) design written in HTML and CSS. Business Logic and Data Model are written in ASP.Net. The very coexistence of all these codes makes the program very complex for maintenance, testing and scalability becomes very difficult.
In .Net there are 2 files generated by Visual Studio .aspx,client-side – markup file containing HTML, CSS, JavaScript, and ASP markup and .cs, server-side – code-behind file. However These 2 files are so tightly coupled, that those files can’t be worked upon separately.
The drag and drop control feature of IDE introduces unwanted code making the program bulky and time consuming to load.
The View State of web forms serializes form inputs prior to post command which takes a huge bandwidth and slows down the application.
In the traditional web form based approach the response time is greater with every event completes entire page life cycle events.
Above issues brings forth the advantages of MVC design pattern. MVC design patterns separate the input, processing, and output of an application. This decouples the input logic, business logic and UI logic and places them separately in an interconnected but loosely coupled model. The UI logic in View, Input logic in Controller, and Business Logic in the Model.This distinct model of separation improves developer’s experience in managing maintenance and testing by dividing the inherent complexity and managing one at a time.
(The controller receives all requests for the application and then instructs the model to prepare any information required by the view. The view uses that data prepared by the controller to bring the final output.)
Model : Represents Data
Model objects are part of the application that implements the logic for the application’s data domain. The model doesn’t know anything about views and controllers. Any changes done in the model notifies observers about the change. The model objects retrieve and store model state in a database. For example, a Customer object might retrieve information from a database, operate on it, and then write updated information back to a Customer table in a database.
View : Represents User Interface
A view is a visual representation the UI of the MVC model.This creates an interface to show the actual output to the user. However, a view will not display anything itself. It is the controller or model that tells view of what to display to the user. Typically, the UI is created from the model data. An example would be an edit view of a Customer table that displays UI Controls based on the current state of a Customer object.
Controller : Represents Business Logic
The controller acts as the interface between the user and system.The brain – the request handler of MVC framework. It works with the model, selects a view to render that displays UI. It provides the user with the input by providing appropriate views to present it appropriately on the screen. The controller understands user output, converts it into the appropriate messages and passes the same to views.
Advantages of MVC model:
Simultaneous Development — Multiple developers can work simultaneously on the model, controller and views. This speeds up development by at least 3 times the traditional approach.
Better Testability – The module separation of the MVC framework provides better testability of the application and supports Test Driven Development (TDD).
Ease-of Modification — Because of the separation of responsibilities, future development or modification becomes easier. The modification in one does not require change in entire architecture. This helps the product to be more scalable.
LooselyCoupled — In MVC framework models, views and controllersare loosely coupled among themselves.
Multiple Views — Models can have multiple views without much of code duplication.
HighlyCohesive — MVC enables logical grouping of related Models, Views and Controllers together.
Lightweight — ASP.Net MVC framework doesn’t use View State which significantly reduces the bandwidth.
SEO Friendly —Using MVC platform, it is very easy to develop SEO-friendly URLs to generate more visits from a specific application.
Cost and Time Benefits —Projects that are developed with the help of the MVC model can be easily developed with less time and cost.
Leave A Comment