domain-driven-design

How are the missing events replayed?

99封情书 提交于 2020-01-04 01:58:12
问题 I am trying to learn more about CQRS and Event Sourcing (Event Store). My understanding is that a message queue/bus is not normally used in this scenario - a message bus can be used to facilitate communication between Microservices, however it is not typically used specifically for CQRS. However, the way I see it at the moment - a message bus would be very useful guaranteeing that the read model is eventually in sync hence eventual consistency e.g. when the server hosting the read model

Injecting service into domain object once again

喜你入骨 提交于 2020-01-03 21:03:09
问题 I've got specific domain that operates on a geographical data. I'm implementing this project in TypeScript and NodeJS and have following classes: Point - value object containing latitude and longitude Area - value object containing set of points as a shape definition Sector - entity (it's not persisted, but it's mutable) - containing area and set of points that lie inside it Now I need implement a method named isPointInside(point: Point) that calculates whether provided point fits inside of

Does “Save” method belong to the Business Domain Entity?

佐手、 提交于 2020-01-03 09:21:54
问题 I am not using any ORM. So I am having a debate whether "Save" method actually belongs to a Business Domain entity or should be abstracted in some service that will be handed over the Business Domain Entity for saving ? e.g. class Employee { string Name; DateTime Birth; GetAge() { } Save() { } } OR class Employee { string Name; DateTime Birth; GetAge() { } } SomePersistenceService { Save(Employee emp) { } } 回答1: Since this question is tagged with 'domain-driven-design', you'll need a

Does “Save” method belong to the Business Domain Entity?

牧云@^-^@ 提交于 2020-01-03 09:21:10
问题 I am not using any ORM. So I am having a debate whether "Save" method actually belongs to a Business Domain entity or should be abstracted in some service that will be handed over the Business Domain Entity for saving ? e.g. class Employee { string Name; DateTime Birth; GetAge() { } Save() { } } OR class Employee { string Name; DateTime Birth; GetAge() { } } SomePersistenceService { Save(Employee emp) { } } 回答1: Since this question is tagged with 'domain-driven-design', you'll need a

Decoupling the model and input checking

一个人想着一个人 提交于 2020-01-03 03:39:27
问题 Is it a good practise to decouple input checking from a model and have it handled elsewhere, say by a controller? If so, how could this be done from an MVC or DDD standpoint? 回答1: It is a good practice to perform UI validation. E.g. if Your domain object expects date time, it is correct if UI part of application ensures it will receive from user correct string, will parse it to date time and pass it to domain object. Bad example: UI part validates if bank account has enough money for transfer

DDD (java) Aggregate roots and persistence

半世苍凉 提交于 2020-01-02 14:49:42
问题 I'm creating an application which will make use of tables of various sizes, while I have worked on a project labeled DDD before it didn't really get the persistence part right and thus I'm left researching things. One thing I don't fully grasp and can't seem to find concrete examples of is how to persist "children" of aggregate roots. I am working without an ORM (just plain old DAO) which is quite hard to find examples of (this is actually a project for uni which is db specific so I'm 'not

DDD (java) Aggregate roots and persistence

蓝咒 提交于 2020-01-02 14:48:10
问题 I'm creating an application which will make use of tables of various sizes, while I have worked on a project labeled DDD before it didn't really get the persistence part right and thus I'm left researching things. One thing I don't fully grasp and can't seem to find concrete examples of is how to persist "children" of aggregate roots. I am working without an ORM (just plain old DAO) which is quite hard to find examples of (this is actually a project for uni which is db specific so I'm 'not

Model-Service decoupling: what if my model needs a service?

余生长醉 提交于 2020-01-02 12:46:08
问题 The Service layer is supposed to be on top of the Model layer. As such, models are not supposed to call services. However, I'm facing a situation where I need to, for example: interface Component { getResult(); } class Number implements Component { private value; public getResult() { return value; } } class Addition implements Component { private component1; private component2; public getResult() { return component1->getResult() + component2->getResult(); } } class ConstantFromExternalSource

Separating the Domain Model and the Data Model

无人久伴 提交于 2020-01-02 12:21:29
问题 My question is similar to this one: Repository pattern and mapping between domain models and Entity Framework. I have done a lot of reading on here about the following: 1) Mapping the ORM directly to the domain model 2) Mapping the ORM to a data model and then mapping the data model to a domain model (and vice versa) I understand the benefits and limitations of both approaches. I also understand the scenarios where one approach is favoured over the other. There are plenty of examples online,

Is it possible to implement MediatR in the Aggregates (Domain Layer) without dependency injection (DDD)?

不羁岁月 提交于 2020-01-02 10:23:18
问题 To prevent reinventing the wheel, I'd like to use MediatR in the Aggregates to publish domain events. (Un)Fortunately(?) MediatR works as a dependency that is injected into the classes, and not something that I can call statically. Therefore I'd end up creating a direct dependency on the library via the constructor. I don't remember where I read it (and if I read it right), that I should avoid non-business dependencies in the constructors of the Aggregates. Therefore, I shouldn't do something