Repositories

Learn how to isolate business logic from data access logic by implementing a repository pattern in the Domain Driven Design world.

Sometimes it is necessary to interact with any type of persistence system in an application. Such a persistence system may be whatever type of SQL or NoSQL database, a file, or even external services. It is important to be able to count on a mechanism that allows us to interact with those systems. The important point here is that business logic remains separate from repository connections logic.

What are repositories?

The first thing to mention is that a repository does not necessarily involve a database. A repository is a pattern that isolates business logic from data store interaction logic. It functions as a collection of objects in memory. It conceals the storage level details needed for managing and querying information of an aggregate in the underlying data tier. When an aggregate wants to interact with information outside of itself, it has to invoke functions in a repository. It only knows a group of objects in memory, it does not know what lies behind such a repository.

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy