MVC , MVP , MVVM
In this blog i am disscussing about Model View Controller (MVC), Model View Presenter (MVP) and Model View-View Model
Model View Controller (MVC)
MVC design pattern splits an application into 3 part : Model , View , Controler
View :
Component dairectly intracy with user and is responsible for how user going to see our application, In MVC , Xml treated as view.
Model :
Model is the data source for application and main bussiness logic is defined here. It contail data objects that are used in application and is show to user . data sorce can be web , local bussiness (Sqlite) etc.
Controller :
Controller is responsible to process incoming request. It receives input from users vie the View, Then proces the User data with the help of Model and passing the result back to view . Typically , it act as the coordinator between view and model.
Model View Presenter
This is similer to MVC pattern in which controller has been replaced by presenter.
Model :
The Model represent a set of classes that describes the business logic and data. also define business rules for data means how the datacan be changed and manipulated.
View :
The view represent the ui componunts. its only responcible for displaying data that is received from the presenter as the result this also transforms the model(s) into UI.
Presenter :
The presenter is responsible for handling all UI events on behalf of the view. This receive input from user vie View, then process the User data with the help of model and passing the results back to the View. Unlike View and Controler and presenter are completly decoupled from each other's and communicate to each other's by an a interface.
Also, preseter does not manage the incoming request traffic as controller.
Key Point about MVP Pattern
- User interface with View.
- There is one to one relationship between View and Presenter means one View is mapped to only one Presenter.
- View has a reference to Presenter but View has nor reference to Model.
- Provied Two way communication between View and Presenter.
Model View ViewModel
This pattern supports two-way data binding between view and View Model. This enables automatic propogation of changes , within the state of View . Typicaly, the View model uses the observe pattern to notify changes in the view model to model.
Model :
As descuss above same info follow above.
View :
As descuss above same info. follow above.
View Model :
The ViewModel is responsible for exposing method, commands , and othe properties thats help to maintain the stage of view , manupulate the model as the result of action on the view, and trigger event in view itself.
Key point about MVVMPattern
- User interact with View.
- There is many-to-onr relationship between View and ViewModel means many View can be mapped to one ViewModel.
- view has refrance to ViewModel but ViewModel no Information about view
- Supports two-way data binding between View andViewModel.
ref. from
-Mahesh Kailash Saraswat



No comments:
Post a Comment