mardi 16 mai 2023

DDD Pattern - Repository and Service concerns

I am working on a modern DDD pattern since a few days (.NET + EF Core) and I have a bit of an hard time to figure how to use correctly a service layer.

I do understand that repositories are there for CRUD related operation and services for more complex logic (like involving multiple entities).

Let say for User entity, all CRUD operation should go into a UserRepository. But things like authentification, access rights, should belong to a service.

So my question is, should the service shallow the repository and expose CRUD operation through it. Or the application should simply use service or directly repository when needed ?

Also, it's easy to understand why the repositories interfaces should go in the domain and theirs implementations in the infrastructure. But what about services ? Some operation are totally related to business logic but some of them are more dependent on the infrastructure.

Could an UserService exist in different area ? Like in the domain and in the infrastructure ?

Thank for your help.

Aucun commentaire:

Enregistrer un commentaire