Although obviously not all scenarios can be covered by a single design, is it generally felt now that ORM classes should be passed to and fro between the presentation and business layer (either local or remote), replacing the need for data transfer objects? As far as I can see, using ORM classes presents problems of unnecessary eager loading, context management issues and tight coupling, but also saves a great deal of time and keeps things simple. Is there now a standard approach that generally favours one over the other (for the majority of situations)?
A DTO is helpful whenever you need to group values in ad hoc structures for passing data around. From a pure design perspective, DTOs are a solution really close to perfection. DTOs help to further decouple presentation from the service layer and the domain model.
A value object is a simple object whose equality isn't based on identity. A data transfer object is an object used to transfer data between software application subsystems, usually between business layers and UI. It is focused just on plain data, so it doesn't have any behaviour.
A data transfer object (DTO) is an object that carries data between processes. You can use this technique to facilitate communication between two systems (like an API and your server) without potentially exposing sensitive information. DTOs are commonsense solutions for people with programming backgrounds.
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.
This is very interesting question and one I have been investigating and experimenting with over the pass two years.
I think there really is no right or wrong answer here. I don't think you can simply say I want one over the other because typically you may want a hybrid depending on what your clients are (webpage,ws,machine and/or local,remote).
The important thing to remember here is what the pros and cons are to each offering and applying this based on your requirements.
For Example:
By wrapping your system in layers and carefully exposing and securing them, you can produce various APIs for many clients of different types.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With