ddd-repositories

could domain models be aware of repositories?

我的未来我决定 提交于 2019-12-06 03:17:25
问题 May be for some domain logic implementation entities need access to repo for update/delete of self or any related entity. Does this sound right ?? 回答1: No, it doesn't, at least for the question tagged with "domain-driven-design" tag. Definitely, Active Record pattern has a right to live in some systems and some people find strong coupling useful, but in DDD the proposed way is to use repositories explicitly: Evans DDD, p.152 : For each type of object that needs global access, create an object

Is it ok for a DDD repository work with summary objects in addtion to “real” objects

不羁的心 提交于 2019-12-05 13:14:14
Say I'm creating a repository to store digital E-Books as shown in the interface below. This repository will store the actual text of the book, as well as the metadata that identifies the book (title, author, publisher, ISBN etc..). public interface IBookRepository { void AddBook(Book newBook); void DeleteBook(int bookId); void UpdateBook(Book updatedBook); Book GetBook(int bookID) } public class Book { public int BookId {get; set;} public string Title {get; set;} public string Author {get; set;} public IList<Page> Contents {get; set} } public class Page { public int PageNumber {get; set;}

Approach for a (generic) DDD Repository with JPA/Spring: does it look wrong?

二次信任 提交于 2019-12-05 02:15:11
问题 I'm pretty new to DDD and JPA. I'm working on a generic Repository with JPA and Spring. I really like the approaches exposed in the articles DDD: The Generic Repository and JPA implementation patterns: Data Access Objects. My aim is to build the perfect Repository in Domain-Driven Design with JPA and Spring. I use an internal generic Repository to respect the domain’s contract with the data store , following the first article concepts. public interface IInternalGenericRepository<K, E> { List

How update an entity inside Aggregate

三世轮回 提交于 2019-12-04 20:35:13
I have an aggregate named Campaigns every with a root entity named campaign, this root entity has a list of attempts (entity) public class Attempts: IEntity<Attempts> { private int id; public AttempNumber AttemptNumber {get;} //other fields } public class Campaign: IEntity<Campaign> //root { private int id; public IList<Attempt> {get;} //other fields } Im using a method to add a campaign attempt public virtual void AssignAttempts(Attempts att) { Validate.NotNull(att, "attemps are required for assignment"); this.attempts.add(att); } Problem comes when i try to edit a specific item in attempts

Persistence encapsulated via the domain, or persistence via the Repository?

送分小仙女□ 提交于 2019-12-04 19:58:14
If my Domain Model is not supposed to know/care about the Repository, then how does some behaviour like .UpdateOrder(...) , that encapsulates a CRUD-Update, interface with the Repository? Through a Domain Service? Ok, then my Repository has an effective CRUD-Update that's used in conjunction with my .UpdateOrder(...) . That's fine. But i don't want someone to use the Update method on the Repository, i want them to go through the behaviour on the Entity (use UpdateOrder() instead). I'd prefer that in likeness to the way my Domain Model satisfies invariants - by it's design (private set

DDD design understanding

╄→尐↘猪︶ㄣ 提交于 2019-12-04 17:00:59
I've been starting to learn about DDD and I have couple of questions so that I can improve my understanding of it. So a typical DDD architecture looks like this Domain Layer => this layer should be technology agnostic and should contain the following Domain.Entities (different from the persistence layer Entities, should contain only validation rules ? any other domain business should go here?) Domain.ValueObjects (objects that do not require to be unique in the domain, should contain only validation rules) Domain.Services (this layer should contain business logic that although related to an

DDD: one-to-many relationship between user aggregate root and almost all entities in other aggregates

北战南征 提交于 2019-12-04 14:29:03
问题 I have the following DDD scenario, grouped into the following aggregates: User, Friends (User Associations), File (for user uploading), Galleries (grouping of files), Messages (user communication), Groups (users can create and other members can join), GroupMessages (messages sent to all members of a group), GroupForums (group members can discuss various topics) This is where it gets confusing. A user is associated with everything down to GroupForums. It seems illogical to have to go through

DDD: Where is it most appropriate to get a list of value objects

牧云@^-^@ 提交于 2019-12-04 11:04:49
I've got a value type called "Product Type" that is assigned to a product. (A product has one product type) To allow the user to select the type from a list, I'm going to fill a dropdown. Where is it most appropriate to retrieve the list of product types? A class implementing a repository pattern? Edit: Clarified by changing product code to product type. A product type is something like "DVD"/"CD"/"Blu Ray"/etc. Product seems to be aggregate root, so list of product types should be in ProductRepository. 来源: https://stackoverflow.com/questions/901462/ddd-where-is-it-most-appropriate-to-get-a

DDD: where should logic go that tests the existence of an entity?

旧街凉风 提交于 2019-12-04 10:42:56
I am in the process of refactoring an application and am trying to figure out where certain logic should fit. For example, during the registration process I have to check if a user exists based upon their email address. As this requires testing if the user exists in the database it seems as if this logic should not be tied to the model as its existence is dictated by it being in the database. However, I will have a method on the repository responsible for fetching the user by email, etc. This handles the part about retrieval of the user if they exist. From a use case perspective, registration

Can the domain model and repositories be in seperate dlls?

元气小坏坏 提交于 2019-12-04 09:50:12
Can the domain model and the repositories be in separate dlls? In a 3 tier architecture I guess I would put the domain model in the business layer and the repositories in the data access layer. I get confused as it is my understanding that the domain model uses the repositories while the repositories should return objects from the domain model, which would cause a circular dependency. I must be misunderstanding one or more of the above concepts. Any clarification would be greatly appreciated as this has been bothering me for a while, thanks. I don't think you should let your domain assembly