Questions tagged [data-transfer-objects]
147 questions
394
votes
12 answers
What is a Data Transfer Object (DTO)?
In MVC are the model classes DTO? If not, what are the differences and do we need both?

Yaron Naveh
- 23,560
- 32
- 103
- 158
154
votes
11 answers
Why are data transfer objects (DTOs) an anti-pattern?
I've recently overheard people saying that data transfer objects (DTOs) are an anti-pattern.
Why? What are the alternatives?

ntownsend
- 7,462
- 9
- 38
- 35
92
votes
15 answers
Why should I isolate my domain entities from my presentation layer?
One part of domain-driven design that there doesn't seem to be a lot of detail on, is how and why you should isolate your domain model from your interface. I'm trying to convince my colleagues that this is a good practice, but I don't seem to be…

Mark Rogers
- 96,497
- 18
- 85
- 138
85
votes
7 answers
Java data transfer object naming convention?
Given this scenario where you have "transfer objects" (POJO's with just getters/setters) which are passed by a client library to your API, what is the best way to name the transfer objects?
package com.x.core;
public class Car {
private…

Marcus Leon
- 55,199
- 118
- 297
- 429
59
votes
4 answers
Difference between Transfer objects and Domain objects
Could you please explain the difference between Transfer objects and Domain objects in simple terms ? And if u could give a Java example, that would be great..

copenndthagen
- 49,230
- 102
- 290
- 442
53
votes
9 answers
DTO or Domain Model Object in the View Layer?
I know this is probably an age-old question, but what is the better practice? Using a domain model object throughout all layers of your application, and even binding values directly to them on the JSP (I'm using JSF). Or convert a domain model…

sma
- 9,449
- 8
- 51
- 80
23
votes
2 answers
What is a DTO and BO? What is the difference?
I know DTO is a data transfer object and a BO is a business object. But, what does it actually mean? When should I choose one over the other?
From, what I understand DTO is just used to transfer data and doesn't have business logic. Does this mean…

Sandbox
- 7,910
- 11
- 53
- 67
21
votes
5 answers
what is a good pattern for converting between hibernate entities and data transfer objects?
I have had similar questions and concerns as to how to convert between Hibernate entities and data transfer objects to be returned by a web service as are discussed in this question:
Is using data transfer objects in ejb3 considered best…

D Parsin
- 731
- 2
- 7
- 17
20
votes
7 answers
Is a Data Transfer Object the same as a Value Object?
Is a Data Transfer Object the same as a Value Object or are they different? If they are different then where should we use a DTO and where should we use a VO?
The programming language we are talking about is Java and the context is - there is a web…

Gaurav
- 1,570
- 4
- 20
- 25
20
votes
2 answers
How to add a file into an already existing dataTransfer object using Javascript
Assumption: A local HTML/Javascript webpage that has access to file://
At the start of a drag on a draggable HTML element, in the event handler function dragStart(e), how do I add a File object so that it is recognized as a file and ends up in the…

Kai
- 326
- 1
- 3
- 6
18
votes
2 answers
What is the purpose of a Data Transfer Object in NestJS?
Im struggling with a problem. Im following the documentation of NestJS. The back-end framework for NodeJS. The documentation mentions a DTO (Data Transfer Object). I created a DTO for creating a user:
export class CreateUserDto {
readonly email:…

Jonathan van de Groep
- 375
- 1
- 3
- 7
18
votes
6 answers
How much business logic should Value objects contain?
One mentor I respect suggests that a simple bean is a waste of time - that value objects 'MUST' contain some business logic to be useful.
Another says such code is difficult to maintain and that all business logic must be externalized.
I realize…

Vivek Kodira
- 2,764
- 4
- 31
- 49
17
votes
2 answers
Can DTO's have nested DTO's?
I have the following domain model:
public class Playlist
{
public long Id { get; set; }
public string Title { get; set; }
public virtual ICollection Songs { get; set; }
}
public class Song
{
public long Id { get; set; }
…

Thomas
- 5,888
- 7
- 44
- 83
16
votes
3 answers
Why do transfer objects need to implement Serializable?
I realized today that I have blindly just followed this requirement for years without ever really asking why. Today, I ran across a NotSerializableException with a model object I created from scratch and I realized enough is enough.
I was told this…

sma
- 9,449
- 8
- 51
- 80
13
votes
3 answers
Javascript DataTransfer items not persisting through async calls
I am using Vuejs along with DataTransfer to upload files asynchronously, and I want to allow multiple files to be dragged and dropped for upload at once.
I can get the first upload to happen, but by the time that upload is done, Javascript has…

trpt4him
- 1,646
- 21
- 34