domain-driven-design

How manage transaction between domain logic and events in DDD?

允我心安 提交于 2019-12-18 16:56:52
问题 I am studying on the programming in DDD and event source. I saw one example that when a domain logic was called (e.g. Order.placeOrder() ) it would publish an event (e.g. OrderPlaced ). And the event would be sent to MQ as the event store. The domain logic ( Order.placeOrder() ) should be an atomic API, and it should have @Transactional annotation if using Spring for the transaction manager. And now my question is: How to make sure the DB change and event sending are within the same

Is Aggregate Root with Deep Hierarchy appropriate in DDD?

走远了吗. 提交于 2019-12-18 16:52:43
问题 I have a system where a user answers question in a form. I have objects representing this model but I am not quite sure how to organize these objects in terms of DDD. Form (has its own list of) Sections; Section -> (has its own list of) Groups; Group -> (has its own list of) Questions; Question ->(can have its own list of sub-questions) Questions; Question -> (has its own list of) Answers; Answer -> (has its own list of) Answer_Details; Answer_Detail -> (potentially has its own list of sub

Should domain objects have dependencies injected into them?

混江龙づ霸主 提交于 2019-12-18 14:57:10
问题 I'm specifically referring to this question: DDD - How to implement factories The selected answer has stated: "factories should not be tied with dependency injection because domain objects shouldn't have dependencies injected into them." My question is: what is the reasoning of not being able to inject dependencies in to your entities? Or am I just misunderstanding the statement? Can someone please clarify? 回答1: Domain Objects aren't Factories, Repos, etc. They are only Entities, Value

DDD Architecture for ASP.NET MVC2 Project

老子叫甜甜 提交于 2019-12-18 13:54:10
问题 I am trying to use Domain Driven Development (DDD) for my new ASP.NET MVC2 project with Entity Framework 4. After doing some research I came up with the following layer conventions with each layer in its own class project: MyCompany.Domain public class User { //Contains all the properties for the user entity } public interface IRepository<T> where T : class { IQueryable<T> GetQuery(); IQueryable<T> GetAll(); IQueryable<T> Find(Func<T, bool> condition); T Single(Func<T, bool> condition); T

Aggregates, Transactional Consistency and the Entity Framework DbContext

こ雲淡風輕ζ 提交于 2019-12-18 13:34:51
问题 Aggregates must be designed to be transactionally and eventually consistency. This consistency boundary around entities helps manage complexity. In our repository implementations, we are using Entity Framework to interface with the actual database. Historically we have always had huge contexts (spanning scores of tables) which represent every available table, field and relationship in the database (or at least in some functional area of the database). The problem here is that this context is

Should Business Objects or Entities be Self-Validated?

依然范特西╮ 提交于 2019-12-18 13:33:21
问题 Validation of Business Objects is a common issue, but there are some solutions to solve that. One of these solutions is to use the standalone NHibernate.Validator framework, which is an attribute-based validation framework. But I'm facing into conceptual concern. Attribute validators like NH.Validator are great but the validation is only performed when save-update-delete within the Session. So I wonder if business objects should not be self-validated in order to maintain their own integrity

Occasionally connected CQRS system

扶醉桌前 提交于 2019-12-18 12:19:59
问题 Problem: Two employees (A & B) go off-line at the same time while editing customer #123, say version #20, and while off-line continue making changes... Scenarios: 1 - The two employees edit customer #123 and make changes to one or more identical attributes. 2 - The two employees edit customer #123 but DO NOT make the same changes (they cross each other without touching). ... they then both come back on-line, first employee A appends, thereby changing the customer to version #21, then employee

DDD: Aggregate Roots

泪湿孤枕 提交于 2019-12-18 11:35:59
问题 I need help with finding my aggregate root and boundary. I have 3 Entities: Plan, PlannedRole and PlannedTraining. Each Plan can include many PlannedRoles and PlannedTrainings. Solution 1: At first I thought Plan is the aggregate root because PlannedRole and PlannedTraining do not make sense out of the context of a Plan. They are always within a plan. Also, we have a business rule that says each Plan can have a maximum of 3 PlannedRoles and 5 PlannedTrainings. So I thought by nominating the

EF code first: How to delete a row from an entity's Collection while following DDD?

本秂侑毒 提交于 2019-12-18 10:57:05
问题 So here's the scenario: DDD states that you use a repository to get the aggregate root, then use that to add/remove to any collections it has. Adding is simple, you simple call .Add(Item item) on the Collection you wish to add to. A new row is added to the database when you save. However, deleting is different - calling .Remove(Item item) doesn't remove the item from the database, it simply removes the foreign key. So while, yes, it is technically no longer part of the collection anymore, it

How value objects are saved and loaded?

一笑奈何 提交于 2019-12-18 10:56:18
问题 Since there aren no respositories for value objects. How can I load all value objects? Suppose we are modeling a blog application and we have this classes: Post (Entity) Comment (Value object) Tag (Value object) PostsRespository (Respository) I Know that when I save a new post, its tags are saved with it in the same table. But how could I load all tags of all posts. Should PostsRespository have a method to load all tags? I usually do it, but I want to know others opinions 回答1: I'm looking for