A big Hello to all my dear readers!
In this post I want to tell you all about the three most popular MV Design patterns in Dot Net Technology. The three patterns addressed here are the MVC, MVVM and MVP.
Model-View-Controller is a software design pattern which was introduced in 1970s. In this design the domain model and controller logic are decoupled from user interface. The design pattern is split into the following three applications :
- Model : This represents a set of classes that describe the business model as well as a data model. The business rules for data, i.e. how the data can be manipulated is also defined by Model.
- View : it represents the UI components and is held responsible for displaying the data that is received from the controller as a result.
- Controller : The controller is responsible to process any incoming requests by receiving the input from the user via View. Then it processes the data with the help of model ad passes the result back to view.
Currently, this pattern is adapted by popular frameworks like Ruby on Rails, Spring Framework, Apple iOS Dev and ASP.NET MVC.
The controller of the MVC pattern is displaced by the presenter here. And therefore, the three main aspects of this design are : Model, View and Presenter.
- Model : The basic functionality of model is the same as in MVC pattern.
- View : View continues to function in the same way as in MVC pattern.
- Presenter : The Presenter handles all UI events on behalf of View by receiving the input from users via the view, process it with the help of Model and pass the result back to the View to display it but it does not manage the incoming request traffic controller. View and Presenter are decoupled and communicate to each other through an interface.
This pattern is commonly used in applications which requires to create automated unit tests for their code-behind pages. It is also used in the windows forms. The user interacts with the View in this pattern and there is a two way communication between View and Presenter.
The Model-View-View Model pattern supports two-way data binding between the View Model and View. as a result of which automatic propagation of changes, within the state of View Model to the view occurs. The latter uses the observer pattern to notify changes in the view model to model.
- Model : The Model part has the same functionality as the previous two designs.
- View : The view also performs the same functions as in the other two models
- View Model : this is responsible for exposing methods, commands and other properties that helps to maintain the state of the view. Iit manipulates the model as a result of actions on the viewer and initiates events in the view itself.
This pattern in generally used by the WPF, Silverlight, nRoute, Caliburn etc.
I hope this article has helped you with a brief knowledge about the .net design patterns addressed. Come back to this space for more informative posts. We always welcome your feedbacks with open arms.
For more info: cpd-india
Batches: Regular & Weekends for Working Profession
For FREE DEMO CLASS CALL – 011-65164822 / 91- 8860352748
Block C 9/8, Sector – 7, Rohini, Delhi – 110085, India
Landmark: Near Rohini East Metro Station, Opposite Metro Pillar No-397