Skip to content

Commit e8b42bd

Browse files
committed
Update README.md
1 parent 2bb2134 commit e8b42bd

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

converter/README.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,28 @@ tags:
99
---
1010

1111
## Intent
12-
The purpose of the Converter Pattern is to provide a generic, common way of bidirectional
12+
13+
The purpose of the Converter pattern is to provide a generic, common way of bidirectional
1314
conversion between corresponding types, allowing a clean implementation in which the types do not
14-
need to be aware of each other. Moreover, the Converter Pattern introduces bidirectional collection
15+
need to be aware of each other. Moreover, the Converter pattern introduces bidirectional collection
1516
mapping, reducing a boilerplate code to minimum.
1617

1718
## Explanation
1819

1920
Real world example
2021

21-
> In real world applications it is often the case that database layer consists of entities that need to be mapped into DTOs for use on the business logic layer. Similar mapping is done for potentially huge amount of classes and we need a generic way to achieve this.
22+
> In real world applications it is often the case that database layer consists of entities that need
23+
> to be mapped into DTOs for use on the business logic layer. Similar mapping is done for
24+
> potentially huge amount of classes and we need a generic way to achieve this.
2225
2326
In plain words
2427

2528
> Converter pattern makes it easy to map instances of one class into instances of another class.
2629
2730
**Programmatic Example**
2831

29-
We need a generic solution for the mapping problem. To achieve this, let's introduce a generic converter.
32+
We need a generic solution for the mapping problem. To achieve this, let's introduce a generic
33+
converter.
3034

3135
```java
3236
public class Converter<T, U> {
@@ -77,7 +81,7 @@ public class UserConverter extends Converter<UserDto, User> {
7781
}
7882
```
7983

80-
Now mapping between User and UserDto becomes trivial.
84+
Now mapping between `User` and `UserDto` becomes trivial.
8185

8286
```java
8387
var userConverter = new UserConverter();
@@ -86,14 +90,18 @@ var user = userConverter.convertFromDto(dtoUser);
8690
```
8791

8892
## Class diagram
93+
8994
![alt text](./etc/converter.png "Converter Pattern")
9095

9196
## Applicability
97+
9298
Use the Converter Pattern in the following situations:
9399

94-
* When you have types that logically correspond which other and you need to convert entities between them
95-
* When you want to provide different ways of types conversions depending on a context
96-
* Whenever you introduce a DTO (Data transfer object), you will probably need to convert it into the domain equivalence
100+
* When you have types that logically correspond with each other and you need to convert entities
101+
between them.
102+
* When you want to provide different ways of types conversions depending on the context.
103+
* Whenever you introduce a DTO (Data transfer object), you will probably need to convert it into the
104+
domain equivalence.
97105

98106
## Credits
99107

0 commit comments

Comments
 (0)