简体   繁体   中英

DDD Model and Rest API

When building a REST web.api should I separate a resource model (a model that is submitted as a parameter in a controller) from a Domain model. Or should these be considered the same thing?

I think I should separate them. The resource model to me should be a simple dto. These are then mapped into the domain model which has all the rich information about how the resource relates to other resources and one place to coordinate business rules. Any finally the domain model saves data via entity models.

It seems that I get model overload Resource Model, Domain Model and Entity Model. And they all look very similar. But by doing so I get a more maintainable application. Do you agree?

When building a REST web.api should I separate a resource model (a model that is submitted as a parameter in a controller) from a Domain model. Or should these be considered the same thing?

Separate. The short answer is that resources belong to the integration domain; changes to the domain model are a side effect of manipulating resources.

See Jim Webber's 2011 talk on domain driven design for RESTful systems

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM