domain-driven-design

How to handle transaction in event driven architecture?

*爱你&永不变心* 提交于 2020-01-14 05:21:12
问题 I'm currently playing with DDD & CQRS, and I moved forward a legacy application. Let's say I have an Article entity, on which I can cast votes. When a Vote is casted on an Article, I want to increment or decrement a counter accordingly to the value of the vote. This counter is part of my Query model and thus I don't think it fits the Domain Model, for such reasons, I decided to write a CastArticleVoteService in which I put the business logic about a vote, and I dispatch an Event to be handle

Is unit of work a good pattern for transactions that will auto generate new objects (auto_increment id)?

拥有回忆 提交于 2020-01-14 00:33:50
问题 From the unit of work pattern i uderstand a method of doing typic transactions based on some domain repostiries (using a repository per domain object) . Example : after defining some repository objects in the UoW object , commit those repositories based on theyr state . Also the repositories should not contain any transaction logic . What happens when an insert() leads to a creation of a new object (auto generated id) that later on is needed by another object in the same transaction ? Unit of

Service layer design. Reason to put things into a service layer

别来无恙 提交于 2020-01-13 20:35:11
问题 I have a few design-related questions: should service layer interfaces reside in a domain layer ? For example user service ? what are the primary reasons to move a code part to a separate layer? should service layer reside at the same assembly as the application layer ? Thanks! EDIT I use a RavenDB and have quite skinny controller actions but two action are present as [NonAction] actions: [NonAction] public IEnumerable<Article> GetAllArticles() { return this.session.Query<Article>()

EF 6: mapping complex type collection?

若如初见. 提交于 2020-01-13 09:59:05
问题 Does EF 6 (code first) supports complex type collection(Value Object collections) mappings? I know that it supports Complex types, but haven't still found an example where we have a collection of complex types. For instance, suppose you have an entity called Student, which has a collection of contacts. With NH, I can simply say that Student has a collection of contacts and that contact is a component (equivalent to complex type in ef). Can this be done with EF without changing contact to an

DDD: is it ok to inject a Service into an Entity

吃可爱长大的小学妹 提交于 2020-01-13 03:20:08
问题 I have a tree of Zone objects: class Zone { protected $parent; public function __construct(Zone $parent) { $this->parent = $parent; } } There are no children nor descendants property in the Zone, because I want to avoid the pain of managing these relationships in the domain model. Instead, a domain service maintains a closure table in the database, to map a zone to all its descendants, at any level. Now, I have a User which can be assigned one or more Zones: class User { protected $zones;

examples of testing the domain using joliver commondomain/eventstore

北城以北 提交于 2020-01-12 18:51:55
问题 I'm looking for good examples of testing the domain using JOlivers CommonDomain and EventStore I have been watching greg youngs videos and he has a nice simple abstract aggregate root test fixture. is there anything like that which can be used with these libs? 回答1: Edit: due to the immaturity of and forced inheritance in CommonDomain, Documently/develop now rolls its own simpler EventRouter Yes, I have a sample here: https://github.com/haf/Documently that shows how you can use it together and

Interface with service layer or domain objects themselves? (DDD)

和自甴很熟 提交于 2020-01-12 08:29:16
问题 I'm still learning about DDD and I have these two (probably simple) questions: If a Factory creates new object/graph/aggregate instances, but also "reconstitutes" objects/graphs from the Repository, then: (1) Does your service layer functions/jobs/tasks/unit-of-work call into the Factory or a behavioural method on the Entity instance or a DomainService function? I'm lost as to the call stack based on the responsibility of these components. (2) Do Entity instances even have "behavioural

DDD: do I really need to load all objects in an aggregate? (Performance concerns)

人走茶凉 提交于 2020-01-11 15:16:53
问题 In DDD, a repository loads an entire aggregate - we either load all of it or none of it. This also means that should avoid lazy loading. My concern is performance-wise. What if this results in loading into memory thousands of objects? For example, an aggregate for Customer comes back with ten thousand Orders . In this sort of cases, could it mean that I need to redesign and re-think my aggregates? Does DDD offer suggestions regarding this issue? 回答1: Take a look at this Effective Aggregate

Repository Pattern: how to Lazy Load? or, Should I split this Aggregate?

老子叫甜甜 提交于 2020-01-11 14:49:06
问题 I have a domain model that has the concept of an Editor and a Project. An Editor owns a number of Projects, and a Project has not only an Editor owner, but also a number of Editor members. Therefore, an Editor also has a number of "joined" Projects. I am taking a DDD approach to modelling this and using the Repository pattern for persistence. However, I don't grok the pattern well enough yet to determine how I should do this. I'm working on the assumption that Editor and Project are

Should i have Parent or ListOfChild property in Hierarcical object

余生长醉 提交于 2020-01-06 20:36:37
问题 i have a doubt on how to model a hierarchical object for storing a Tag tree: thinking to db table i can use public class Tag { public int Id { get; set; } public int Description { get; set; } private readonly Tag parentTag; public Tag ParentTag { get { return parentTag; } } } the code from parent property come from Hierarchical object and AutoFixture to avoid circular reference but as suggested there, and thinking to object maybe is better having child collection instead of parent: naturally