DRY vs Security and Maintainability with MVC and View Models

前端 未结 2 1231
长发绾君心
长发绾君心 2021-02-09 20:32

I like to strive for DRY, and obviously it\'s not always possible. However, I have to scratch my head over a concept that seems pretty common in MVC, that of the \"View Model\"

2条回答
  •  孤城傲影
    2021-02-09 20:43

    One could also note that not using view models would be a violation of the single responsibility principle -- your entity should not be polluted with UI concerns.

    I also think the real value of view models doesn't necessarily become apparent in version 1.0 of your application. You will thank yourself when working on version 2.0 when you completely re-think how your back-end works but you don't have to carry those changes out to the view layer.

提交回复
热议问题