Skip to content

Commit 8512c65

Browse files
committed
Update README.md
1 parent 6373f7b commit 8512c65

1 file changed

Lines changed: 17 additions & 11 deletions

File tree

data-transfer-object/README.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,34 @@ tags:
99
---
1010

1111
## Intent
12-
Pass data with multiple attributes in one shot from client to server, to avoid multiple calls to remote server.
12+
13+
Pass data with multiple attributes in one shot from client to server, to avoid multiple calls to
14+
remote server.
1315

1416
## Explanation
1517

1618
Real world example
1719

18-
> We need to fetch information about customers from remote database. Instead of querying the attributes one at a time, we use DTOs to transfer all the relevant attributes in a single shot.
20+
> We need to fetch information about customers from remote database. Instead of querying the
21+
> attributes one at a time, we use DTOs to transfer all the relevant attributes in a single shot.
1922
2023
In plain words
2124

2225
> Using DTO relevant information can be fetched with a single backend query.
2326
2427
Wikipedia says
2528

26-
> In the field of programming a data transfer object (DTO) is an object that carries data between processes. The
27-
motivation for its use is that communication between processes is usually done resorting to remote interfaces
28-
(e.g., web services), where each call is an expensive operation. Because the majority of the cost of each call is
29-
related to the round-trip time between the client and the server, one way of reducing the number of calls is to use an
30-
object (the DTO) that aggregates the data that would have been transferred by the several calls, but that is served by
31-
one call only.
29+
> In the field of programming a data transfer object (DTO) is an object that carries data between
30+
> processes. The motivation for its use is that communication between processes is usually done
31+
> resorting to remote interfaces (e.g. web services), where each call is an expensive operation.
32+
> Because the majority of the cost of each call is related to the round-trip time between the client
33+
> and the server, one way of reducing the number of calls is to use an object (the DTO) that
34+
> aggregates the data that would have been transferred by the several calls, but that is served by
35+
> one call only.
3236
3337
**Programmatic Example**
3438

35-
Let's first introduce our simple customer DTO class.
39+
Let's first introduce our simple `CustomerDTO` class.
3640

3741
```java
3842
public class CustomerDto {
@@ -60,7 +64,7 @@ public class CustomerDto {
6064
}
6165
```
6266

63-
Customer resource class acts as the server for customer information.
67+
`CustomerResource` class acts as the server for customer information.
6468

6569
```java
6670
public class CustomerResource {
@@ -94,10 +98,12 @@ Now fetching customer information is easy since we have the DTOs.
9498
```
9599

96100
## Class diagram
101+
97102
![alt text](./etc/data-transfer-object.urm.png "data-transfer-object")
98103

99104
## Applicability
100-
Use the Data Transfer Object pattern when
105+
106+
Use the Data Transfer Object pattern when:
101107

102108
* The client is asking for multiple information. And the information is related.
103109
* When you want to boost the performance to get resources.

0 commit comments

Comments
 (0)