webdevilopers / php-ddd

PHP Symfony Doctrine Domain-driven Design
201 stars 10 forks source link

Read models vs. View models #43

Open webdevilopers opened 4 years ago

webdevilopers commented 4 years ago

Came from:

/cc @matthiasnoback @ashishkpoudel @cherifGsoul @stemmlerjs

Just finished reading your "Web Application Architecture" book @matthiasnoback . I finally understood the difference between READ and VIEW models. In your chapter about layers you suggest to put VIEW models into the application layer. But where to put the READ models? Since in #CQRS for instance a read model represents the state of the write model, some people state it should belong to the domain layer. I agree VIEW models are optimized for presentation and should live elsewhere. E.g. application or as we like to add a "presentation" layer.

@matthiasnoback states:

I'm not sure if the distinction between read and view model is a very common one. For a view model is used to expose data to actors (e.g. users). A read model exposes data to the system itself (i.e. it's for internal use). It makes sense to put that one in the domain layer.

Related:

webdevilopers commented 4 years ago

Similar question by @cer:

Another #eventstorming question: Read Models are typically depicted as being consumed by humans. But arguably a command triggered by, for example, a policy needs a "Read Model". Thoughts ?

/cc @ziobrando @tPl0ch

@tPl0ch states:

I personally don't like the term read model. The important part is the decision that is taken, either by a policy or a human, and that the decision can be taken locally. To do this all the required information needs to be present. So maybe decision model would be a better name?

@ziobrando states:

Yep, totally on you on the rationale. Don’t know if that’s a compelling reason for a name change #Lazy. I just say “a read model is a decision support tool” ...decision model could be misinterpreted in some other ways, I am afraid.

cherifGsoul commented 4 years ago

I had always considered Read Models and View Model the same, they are just object to carry data to UI layer where the later can format those data for presentation.