✅ Repository Pattern question.
While incorporating the Repository Pattern should the repository class itself remain as agnostic as possible and only rely on the functions passed through from the database context class making it as agnostic as possible or should it include code tightly bound to the database context, i.e. actual code to manipulate the database.
More or less what I'm trying to say if the code for actually interacting with the database (CRUD operations) should come from the database context and or be in the repository itself (assume I'm using a local, self-contained NoSQL database).
3 Replies
I'd really not go all zealot on it.
while repository patterns help us abstract away the DB from the business logic layer, most often then not those are leaky abstractions that expose the internal details to the business logic.
What do I do with a repository pattern?
* expose the DB/service access to reflect strictly what the business domain requires, i.e. answer the business questions related to the inquiry.
* be able to introduce additional logic, like retries, back-offs, caches etc' without exposing those details to the business layer, since they have nothing to do with business.
I really hope it answers your question 🙂
It definitely did 😚
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.