lundi 23 juillet 2018

The change in domain model makes me also change DTO when I try to implement rest api. So, what is the use of DTO

When one decides to refactor or change the domain model, one also has to change the DTO. For example, there is "Customer" class being one of the domain models then there was created "CustomerDTO" class with the purpose that if any change is done to Customer class, API willnot be broken.

But if we decide to, say, remove or rename a property in domain model, we also have to make change to DTO so why on earth should I use DTO then.

Also, DTO leads to violation of DRY principle.

Can you explain in detailed and clear way why DTO is recommended to be used with WEB API when I can achive the same by using domain model and without any middleman and just change domain model and not worry about the change that needs to be done in DTO.




Aucun commentaire:

Enregistrer un commentaire