I am developing an application which will use user sessions stored both in the client and on servers. Should I treat them as different repository implementations and use DI to use them inside domain services? Any suggestions?

1 Answer 1


Without knowing your context, the concept of "user sessions" sounds a lot like an infrastructure concern your domain layer shouldn't care about. So yes, as long as client vs. server user sessions isn't a domain concept, I would hide the technical origin of that data from the domain by injecting a service.

Whether that service is a repository (which is usually an abstraction for loading domain objects), I cannot say - that again depends on your domain. Are you loading aggregates/entities from the user sessions? If so, the service seems to be a repository. If not, it's probably not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.