mardi 14 avril 2020

Why repository should not return DTO

Read a lot of articles where people say that I should return Domain Model... But that will ruin the whole idea of my repository then.

I am using laravel Eloquent Models (that, if I am correct - Domain Models). I have repository, so in case I will decide to switch to Doctrine, I could just swap it all in a service provider. But if I will return an instance of Domain Model (in this case, Eloquent Model) that makes no sense. I need to return the same result from repository, and DTO seems just what I need...

Can someone explain me why am I wrong?

Aucun commentaire:

Enregistrer un commentaire