Model View ViewModel Presenter pattern in the Kitchen
To better illustrate my self cooked MVVMP pattern I have created the following image
Here chicken is the model and the person is the view. This means that view ultimately consumes the model but before it is in consumable form it has to go through Presenter (i.e. get cooked) and then presented in a ViewModel (plate) to consume from. This is the most sane way of doing things.
Now in a typical MVVM pattern what people do is that they combine the presenter and viewmodel into one thing called ViewModel i.e. they add business logic in the viewmodel instead of separating it in Presenter. So semantically it means that people tend to eat straight from the pressure cooker when the food is ready instead of pouring it in the plate. For them the cooker not only cooks but also serves as the container to eat from.
In MVVMP the ViewModel contains the properties solely for the purpose of data binding on the view and holding references to ICommand . Presenter contains IView and ViewModel references and acts as a command and control center for both.
So yes Tom (the person) can practically eat the chicken directly from the cooker once it is cooked but that won’t be very civilized way of doing things similarly in the world of programming MVVM doesn’t seem civilized to me therefore we have MVVMP (Model View ViewModel and Presenter) pattern.
Categorised as: Programming