Are current MVVM view model practices a violation of the Single Responsibility Principle?

后端 未结 4 1008
天涯浪人
天涯浪人 2021-02-01 20:02

With current practices (at least with WPF and Silverlight) we see views bound via command bindings in the view model or we at least see view events handled in view models. This

4条回答
  •  伪装坚强ぢ
    2021-02-01 20:57

    What it boils down is that the view model is a composite of the following:

    • an abstraction of the view
    • commands
    • value converters
    • view state

    I don't see why you've separated the first two items. Commands are part of the view.

    As for the rest - you're right. In some cases. I've built applications where the tasks of value conversion and maintaining view state were sufficiently complex that it didn't make sense for a single view model class to do it all, and I broke them out into separate classes that interoperate with the VMs.

    So?

提交回复
热议问题