domain-driven-design

DDD - Association mapping between bounded contexts using Doctrine 2

孤街浪徒 提交于 2021-02-18 12:50:28
问题 I am struggling to understand the right way to implement association mapping between two entities from different bounded contexts using Doctrine 2. Suppose that there are two "User" and "Post" entities that belong to "User" and "Content" bounded contexts, respectively. There is also a "User" concept in "Content" context that determines the author of a "Post" through a Many-To-One association. Therefore, "User" in "Content" context is simply a value object containing the user id. My question

Domain validation using the notification pattern

十年热恋 提交于 2021-02-16 13:57:26
问题 Historically I have performed validation of my objects within their constructors and thrown an exception when validation fails. For example: class Name { const MIN_LENGTH = 1; const MAX_LENGTH = 120; private $value; public function __construct(string $name) { if (!$this->isValidNameLength($name)) { throw new InvalidArgumentException( sprintf('The name must be between %d and %d characters long', self::MIN_LENGTH, self::MAX_LENGTH) ); } $this->value = $name; } public function changeName(string

Domain validation using the notification pattern

荒凉一梦 提交于 2021-02-16 13:57:06
问题 Historically I have performed validation of my objects within their constructors and thrown an exception when validation fails. For example: class Name { const MIN_LENGTH = 1; const MAX_LENGTH = 120; private $value; public function __construct(string $name) { if (!$this->isValidNameLength($name)) { throw new InvalidArgumentException( sprintf('The name must be between %d and %d characters long', self::MIN_LENGTH, self::MAX_LENGTH) ); } $this->value = $name; } public function changeName(string

How to manage two coupled aggregates in DDD?

十年热恋 提交于 2021-02-11 14:09:23
问题 I am developing Electric Vehicle Charging Station Management System, which is connected to several Charging Station s, and I am in an impasse. In this domain, I've come up with an aggregate for the Charging Station , which includes the internal state of the Charging Station (whether it is connected, the internal state of its Connectors). It has a UnlockConnector method, for which, to accurately respect its name(and not be anemic) it sends the request to the respective Charging Station , as it

DDD and batch processing (e.g. using Spring batch)

对着背影说爱祢 提交于 2021-02-11 01:14:47
问题 I would like to use Spring batch for a batch application. I already have a domain model designed following DDD. My question is how batch processing (in my case, using Spring batch) fits with DDD? For example, I have an aggregate root A and one of its children is the entity B. A has a list of one or more Bs. The batch application receives a file when each line corresponds to an operation (add, delete...) on the list of Bs. In my aggregate root A, I have one method for each operation (e.g. addB

DDD - aggregate root identity usage across bounded context bounderies

谁说胖子不能爱 提交于 2021-02-09 11:52:43
问题 One suggested way to model entity identities in a domain model is to create value objects instead of using primitive types (f.e. in C#): public class CustomerId { public long Id { get; set; } } In my opinion this classes should be used throughout the whole application and not only in the domain model. Together with commands and events they can define a service contract for a bounded context. Now in an message/event driven architecture with multiple bounded contexts and each having a separate

Should we trust the repository when it comes to invariants?

老子叫甜甜 提交于 2021-02-08 21:17:03
问题 In the application I'm building there are a lot of scenarios where I need to select a group of aggregates on which to perform a specific operation. For instance, I may have to mark a bunch of Reminder aggregates as expired if they meet the expiration policy (there is only one). I have a ReminderExpirationPolicy domain service that is always applied before delivering reminders. This policy does something like: reminderRepository.findRemindersToExpire().forEach(function (reminder) { reminder

Should we trust the repository when it comes to invariants?

a 夏天 提交于 2021-02-08 21:16:26
问题 In the application I'm building there are a lot of scenarios where I need to select a group of aggregates on which to perform a specific operation. For instance, I may have to mark a bunch of Reminder aggregates as expired if they meet the expiration policy (there is only one). I have a ReminderExpirationPolicy domain service that is always applied before delivering reminders. This policy does something like: reminderRepository.findRemindersToExpire().forEach(function (reminder) { reminder

Should we trust the repository when it comes to invariants?

风流意气都作罢 提交于 2021-02-08 21:09:51
问题 In the application I'm building there are a lot of scenarios where I need to select a group of aggregates on which to perform a specific operation. For instance, I may have to mark a bunch of Reminder aggregates as expired if they meet the expiration policy (there is only one). I have a ReminderExpirationPolicy domain service that is always applied before delivering reminders. This policy does something like: reminderRepository.findRemindersToExpire().forEach(function (reminder) { reminder

Should we trust the repository when it comes to invariants?

China☆狼群 提交于 2021-02-08 21:09:41
问题 In the application I'm building there are a lot of scenarios where I need to select a group of aggregates on which to perform a specific operation. For instance, I may have to mark a bunch of Reminder aggregates as expired if they meet the expiration policy (there is only one). I have a ReminderExpirationPolicy domain service that is always applied before delivering reminders. This policy does something like: reminderRepository.findRemindersToExpire().forEach(function (reminder) { reminder