Are the advantages of Model-View-ViewModel (MVVM) pattern worth the overhead?

前端 未结 4 1415
执笔经年
执笔经年 2021-01-04 21:15

The question is stated in the subject: are the advantages of Model-View-ViewModel (MVVM) pattern worth the overhead?

In many cases, implementing the view model invo

4条回答
  •  一整个雨季
    2021-01-04 21:43

    Why not extending the Model class, providing additional properties to make it easy to be consumed by the View instead?

    Effectively that is what the PresentationModel is for. Which MVVM is strongly based on. The difference is that the ViewModel is the model for the view and not the model for the data. So you are concerned around more how the view behaves with the data.

    If you have a simple UI that all it does is present the model then I would suggest expose the Model on a property of the ViewModel and bind to that. Make sure though the model does implement INotifyPropertyChanged etc.

    The power of the ViewModel is when you have things to do in response to a user action. The ViewModel can then support Commands, calling out to services and validation and thus leaving the Model as a data container

提交回复
热议问题