I have a question about Repository design pattern, exactly how to interact with many data sources.
For example, i have these repositories:
- UserRepositorySql
- UserRepositoryMongo
- UserRepositoryXml
(Is this even correct? i mean to create an repository for each data source?)
What is better:
-
An abstract class called UserRepository and the other ones extend from UserRepository.
-
Just an interface for these 3 Repositories.
Im not clear to how to retrieve an specific repository for an specific data source, if i use an abstract class, i could implement an UserFactory (factory pattern) class that returns me the specific repository object. (Is this even correct ?)
But how could i retrieve an specific repository if i use an interface? (Since factory pattern needs an parent abstract class, am i right?)
Also when i say "an specific repository" i mean receive a repository with its specific data source.
Thank you so much, redigaffi.
Aucun commentaire:
Enregistrer un commentaire