Slimer
Slimer

Reputation: 1163

Is a repository only limited to the database in domain driven design?

When talking about a repository, everyone imagines abstraction over a database.
But can a repository be abstracted over a REST service or some other source of loading aggregates?

Upvotes: 1

Views: 115

Answers (2)

Sylvain Lecoy
Sylvain Lecoy

Reputation: 1017

Yes totally it can even be an implementation of an event store.

The abstract concept is a repository, that's all that matter to the domain, nothing else.

Implementation details belong to infrastructure (and are called port adapters).

Upvotes: 4

VoiceOfUnreason
VoiceOfUnreason

Reputation: 57194

But can repository be abstraction over REST service or some other source of loading aggregates?

Yes. Evans's motivation for the repository pattern was to provide the application with the illusion that the collection of aggregates live in memory; providing a clean separation between the the code that needed to understand the details of persistence from the code that does not.

See Domain Driven Design, chapter 6.

Upvotes: 3

Related Questions