51
votes
Accepted
Which layer do DDD Repositories belong to?
Repositories and their placement in the code structure is a matter of intense debate in DDD circles. It is also a matter of preference, and often a decision taken based on the specific abilities of ...
44
votes
Accepted
Should Entity Framework 6 not be used with repository pattern?
To get this out of the way, I am a big proponent of Entity Framework, but it does come with some drawbacks that you need to be aware of.
I also apologize for the long answer, but this is a very hot ...
23
votes
Accepted
How to structure microservices in your repository
No code reuse is usually understood as a selling point for microservices!
the microservices can be developed and deployed independently
different microservices can use different technologies, in ...
23
votes
Accepted
Is unit of work pattern really needed with repository pattern
The Entity Framework DbContext is a unit of work, and its DbSet<T> properties are repositories.
That's not to say that you should never roll your own layer on top of them, but you're correct in ...
15
votes
Is it a good idea to share repositories across microservices in Spring Boot Application?
I vehemently opposed
Vehemence makes others stop listening and limits our perception, hence our capacity to find solutions too.
In my experience, we are vehement at defending or opposing ideas we don'...
14
votes
Accepted
Access multiple entities in repository - clean architecture
Your repository doesn't break the "clean architecture", which identifies entities as the core, requires dependency inversion, but doesn't impose to use repositories.
But your repository ...
13
votes
Which layer do DDD Repositories belong to?
Which layer Repositories belong: the Domain Layer, Persistence Layer or something in the middle?
If you believe in dependency inversion*, then repositories are contracts defined by the application ...
13
votes
Is unit of work pattern really needed with repository pattern
The Unit-Of-Work pattern makes sense when you have a complex use case with several objects involved, often objects which map to different master-detail tables. As part of the use case, you want to
...
13
votes
Should access control be implemented in controller or repository layer?
Ideally, if you really require a high level of security, the DB itself should not return any data for which the requester does not have the permission. With this idealistic idea in mind, the answer ...
12
votes
Accepted
Repository pattern, call another API that updates a SOR's from service or repository class?
The calls to other APIs should go in the repository layer.
The service layer shouldn't care how it gets its data, no matter where that data comes from.
The job of a repository isn't communicating ...
12
votes
Accepted
Data Repository and Complex Queries (DTO)
To cut a long story short, this is mostly a matter of self-imposing a design and then trying to make something fit. Something which is very much needed, but doesn't quite fit with the design we ...
10
votes
Is it an anti-pattern to use interface for entity?
Without the full context of this article, it's impossible to say exactly what the point of it was but I think I can provide a useful answer to your question.
The first bullet "Your interface ...
10
votes
Accepted
What is the correct way to configure a testing mode on a class?
You should use a different approach. The commonly advised approaches are
Use DI to inject the firestore object into your repository class instance. This way, your test framework can just inject a ...
9
votes
Accepted
Is it acceptable to invoke business logic inside the repository layer?
Is it acceptable to invoke business logic inside the repository layer?
The DDD police are not going to come and kick down your door.
But...
The motivation for the repository pattern is to "decouple ...
9
votes
Avoiding Repository pattern - implementing Onion Architecture with DbContext only
The core argument for using repositories is to prevent leaking EF dependent code into your domain. That argument is not wrong, it just comes with a steep cost, i.e. a high-complexity uow/repo layer, ...
9
votes
Accepted
To which Clean Architecture layer should repositories implementations belong?
Here is where practice meets reality. And surprisingly, R.C.Martin didn't address this question in his book despite some code examples like that.
Where's the repository interface?
So repository is an ...
9
votes
Accepted
What data type should a repository return?
In domain driven design, repositories are created for aggregate roots only.
Here's what Eric Evans wrote in chapter 6, defining what he intended by REPOSITORY
For each type of object that needs ...
8
votes
Repository Pattern vs DAL Object Creation
My understanding is:
DAL (Data Access Layer) refers to a layer in your software that sits between your persistence technology and your application logic. Its purpose is to keep data access concerns ...
8
votes
Generic repository pattern +EF and unit of work
It should satisfy SOLID principles
A laudable goal, but does it help you satisfy any of your software's functional and non-functional requirements?
The purpose of the SOLID principles is to help you ...
8
votes
Which layer do DDD Repositories belong to?
The repository interface belongs in the domain layer. The repository implementation should be elsewhere, but the literature is not clear. Options include: infrastructure layer (probably the most ...
8
votes
Should access control be implemented in controller or repository layer?
Security should be applied by your framework before the Controller.
In most frameworks this means you grant access to Controller Methods.
Controller
The controller will have access to the ...
8
votes
To which Clean Architecture layer should repositories implementations belong?
A repository lives in the data layer. That is the short and simple answer.
it's doing the work of an adapter(just adapting the fetch logic format of MongoDatabase to another format easier to use)
...
7
votes
Data Entities, Domain entities and the repositories
Okay. There is a lot to unpack here, but the I think the root cause of some of your confusion is stemming from starting this process with the physical model at the forefront. This commonly causes all ...
7
votes
Accepted
Repository Pattern with Services Layer - Good Practice?
he divided his solution into 4 projects. Core, Data, Services and WebApi
Just as a hint for finding more documentation on the subject: Core, Data, Services sounds a lot like the Domain, Persistence (...
7
votes
Accepted
Are repositories async?
Today, you'd typically make it async. There was a time when mainstream languages and their standard libraries didn't have async/await or things like promises and futures, so you had to do things with ...
7
votes
Accepted
How to structure repositories for a small number of entities?
In DDD, the general approach is to have one repository per aggregate.
An aggregate is a collection of closely related concepts that together form a consistency boundary.
For example an Order aggregate ...
6
votes
Accepted
Hexagonal Architecture and database concurrency
The core idea of the hexagonal architecture is that the business logic defines various interfaces, and external systems are adapted to this interface.
For example, if the business logic wants to be ...
6
votes
Data Entities, Domain entities and the repositories
It seems that you have seen someone implementing a DDD design using the architecture you mention in the question, but that is not what DDD is. That is just one of many possible implementations. I ...
6
votes
Where to place POCOs validation - N-layers architecture
A. Where can I place the validation?
Regardless of your design there are two places where validation code goes:
Near input
Near use
You put validation near input so that you can show the user the ...
6
votes
Accepted
Is it ok for Repository Pattern to contain unusual method names?
At the repository level I would recommend having a more generic method like Find(User user) or findUserByNameAndStatus(name, status). Getting overly specific like your example is unlikely to be a ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
repository-pattern × 140domain-driven-design × 43
c# × 22
design-patterns × 22
repository × 18
architecture × 17
entity-framework × 16
unit-of-work × 13
database × 9
clean-architecture × 9
design × 8
asp.net-core × 7
entity × 7
dependency-injection × 6
architectural-patterns × 6
cqrs × 6
orm × 6
persistence × 6
layers × 5
aggregate × 5
java × 4
unit-testing × 4
android × 4
patterns-and-practices × 4
object-oriented × 3