Should I implement business logic on a Model or a ViewModel

后端 未结 4 751
走了就别回头了
走了就别回头了 2021-01-04 11:28

When I\'m processing business logic in an MVVM app. Should I do this on the Model or the ViewModel?

For example, if I want to re-calculate costs after an Asset has b

4条回答
  •  情深已故
    2021-01-04 12:16

    My suggestion is to put logic in a service layer instead. This is a middle layer between view model and model (which, in a real object oriented paradigm, should only contains properties). So the correct life circle may be: View model -> service -> model handling. This allows also to reuse business logic code through others view model if needed

提交回复
热议问题