Value Objects in CQRS – where to use

Ok I’ve changed my mind. I have been trying to deal with VOs a bunch lately and after watching this http://www.infoq.com/presentations/Value-Objects-Dan-Bergh-Johnsson it clarified a couple of things for me. Commands and Event are messages (and not objects, objects are data + behavior), in some respects much like DTOs, they communicate data about an event and … Read more

Should the repository layer return data-transfer-objects (DTO)?

Short answer: No. Long answer: repository is responsible for turning persisted data back to entities (models) and vice versa. Model is a business Model representing a business entity. DTO on the other hand – while looks like Model – is concerned with transfer of the object between various environment and in essence is a transient … Read more

DTO naming conventions , modeling and inheritance

Recommendation is that you should just have one DTO class for each entity suffixed with DTO e.g. CustomerEntryDTO for the Customer entity (but you can certainly use inheritance hierarchies as per choice and requirements). Moreover, Add a abstract DTOBase kind of base class or an interface; and do not use such deep inheritance heirarchies for … Read more

Reusing DTO for various request/response types vs explicitness of what is required / what should be returned [closed]

Separate, simple DTOs will make your life infinitely easier. It will require more code, but it will be boring, simple code, that is easily tested, and allows your interfaces to change and evolve independently. Make a DTO for each request endpoint and a separate DTO for each response. Otherwise, you will eventually be sad. If … Read more

Difference between Entity and DTO

Short answer: Entities may be part of a business domain. Thus, they can implement behavior and be applied to different use cases within the domain. DTOs are used only to transfer data from one process or context to another. As such, they are without behavior – except for very basic and usually standardised storage and … Read more

What is the difference between an MVC Model object, a domain object and a DTO

Domain and model objects are essentially the same, and may contain business logic. Depending on implementation, domain and DTO objects may be equivalent if you remove business logic from the model into a service class. Often a key variant of the DTO is the View Model, which is used purely to transfer data between the … Read more