In CQRS, should my read side return DTOs or ViewModels?

前端 未结 4 1158
太阳男子
太阳男子 2020-12-23 16:59

I\'m having a debate with my coworkers in the design of the read side of a CQRS application.

Option 1: The application read side of my CQRS applicat

4条回答
  •  一向
    一向 (楼主)
    2020-12-23 17:55

    I would prefer to return DTO to separate the application layer from presentation technology (because each presentation technology may have some requirements on the structure of presentation model) for example a web MVC application binding is different than WPF MVVM binding, also you may require some properties/fields in view models that has nothing to do with application data like for example (SliderWidth, or IsEmailFieldEnabled, ...). Also for example if using WPF MVVM i would need to implement INotifyPropertyChanged interface to allow binding it is not convenient nor related to implement this interface in the application read service.

    so i would prefer separating the concern of read data representation from the actual presentation technology and view model.

    So option 1 is better for me

提交回复
热议问题