lundi 30 septembre 2019

Do I need a data transfer object pattern from client to server?

I am putting together a simple REST based web-service backend using Spring. I have a domain model called User which contains all of the possible fields that a certain user need within the life-cycle of application. Depending on which way the information is flowing, I am using a certain POJO.

For serialization/marshalling:

Persistence (database) > UserDao > User > UserService > UserController > UserDto > Client

OR

Persistence > UserDao > User > UserService > FriendsService > FriendsController > FriendsDto > Client

Where UserDto encapsuates select few fields from the User.

What pattern should I use for the other way around (deserialization/unmarshalling) when I am mapping POST requests from client?

Client > UserController > UserSomePattern? > UserService > UserDao > Persistence

Similarly, UserSomePattern will map certain fields from User but not necessarily ditto as UserDto. What should my UserSomePattern POJO be called, if any?

Aucun commentaire:

Enregistrer un commentaire