Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply Entity and Aggregate Domain-Driven Design approach to Specification and Repository #384

Closed
elyosemite opened this issue Feb 1, 2024 · 2 comments

Comments

@elyosemite
Copy link

In a Domain-Driven Design approach, we have aggregates and entities, so it is common to see markup interfaces such as IAggregateRoot and IEntity.

That being said, it wouldn't be interesting to think about Specification applied to an entity, so you've already considered - in the Ardalis.Specification nuget - using it in the following way:

public interface ISpecification<T> where T : IEntity.

And the second solution would be for repositories, in which it would only allow using IAggregateRoot.

public interface IReadRepositoryBase<T> where T : IAggregateRoot.

@fiseni
Copy link
Collaborator

fiseni commented Feb 2, 2024

Hi @elyosemite,

That's way too opinionated. Forcing everyone to apply IEntity to all entities will piss off everyone.
This library is agnostic to how you organize your codebase, or what architectural decisions you've made. That's up to you as a consumer. You may not even be using repositories, and that's fine; use specifications without repositories.

Yes, the specifications play nicely with repositories. And if you choose to do so, then please check our samples (in the sample folder in this repo). In Sample3 we have an example implementation using read and write repositories; where the write repository is constrained to only aggregate roots (entities marked with IAggregateRoot).

@fiseni fiseni closed this as completed Feb 2, 2024
@elyosemite
Copy link
Author

Awesome!!! Thanks for the observations. <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants