Questions tagged [aggregate]

An aggregate is either a group of related objects/data or the result of some operation on such group. The tag can be used for example for language specific data structures, algorithms that combine data and GROUP BY queries, UML relationships, or DDD aggregates that combine dependent objects.

0
votes
1answer
58 views

Storing within the domain or use CQRS?

Assume we're building a fleet management system that is monitoring telemetry on a fleet of cars. Important telemetry include like location, speed and engine temperature. Metrics are mostly dynamic and ...
0
votes
1answer
52 views

Keep all user orders in a single aggregate instance

I'm thinking of not keeping user orders as separate Aggregate instances, but combine them into one UserOrders. Is such an approach going to have some flaws in terms of DDD? Along with orders, I would ...
-2
votes
1answer
71 views

A basic question on DDD aggregates order and payment

There's is a statement from https://martinfowler.com/bliki/DDD_Aggregate.html: An aggregate will have one of its component objects be the aggregate root. Any references from outside the aggregate ...
0
votes
2answers
77 views

F# DDD Bank Modelisation: Aggregate Design for Event Sourcing

I am designing a toy project dealing with the bank account management in F# with Event Sourcing. I would like to get a bit of review (not really a code review) about my Commands and Events to see if ...
0
votes
1answer
54 views

Using the same entity for different use cases

Suppose I have a User entity with name and age attributes. A User can own Boxes. A Box has the name and color attributes. Business rules dictate that one User can own at most 5 boxes. So, in this case,...
1
vote
2answers
54 views

DDD different aggregates for the same model but different sagas / use cases?

I have an invoice aggregate that I create with a lot of data: $invoice = Invoice::create( InvoiceId::generate(), $lines, // Collection of lines InvoiceNumber::create('1'), $address, //...
2
votes
1answer
123 views

DDD - Creating and modifying my root aggregate based on request data

I have an invoice root aggregate that has many invoice line entities, a due date value object and two reminder entities. We're not using event sourcing yet. The post data I receive from the form the ...
0
votes
2answers
92 views

performance suggestions on Aggregate root containing thousands of child entities

I understand that DDD is a design concept and implementation through ORMs are tricky but help me understand how would you solve this problem? So here is my confusion on changing on aggregates only ...
0
votes
1answer
55 views

Can Aggregate shared between services?

I am working in an event-sourcing architecture and while creating the aggregates I came to an interesting challenge, disclaimer I'm new to this. I have a UserAggregate encapsulating the logic for ...
0
votes
1answer
157 views

Modify a property of an aggregate's entity

Suppose I have a house-lending service, like Airbnb. I have a House entity, which can have a name. There's also the Reservation entity, which has a start date, an end date, and a name (which isn't ...
0
votes
0answers
66 views

DDD: aggregate root and references to child entities

I'm struggling a bit to grasp all DDD concepts and apply them to a real project. Let's say I have the following domain concepts: Car: a vehicle moving inside an area Path: a journey made by a car, ...
0
votes
0answers
92 views

DDD: How to (mass) update aggregate roots?

I want to (mass) update aggregate roots with data from a leading external system. To do so a scheduler runs a task which fetches updates for my existing objects and data for new objects from the ...
0
votes
1answer
116 views

DDD: Aggregate with nested childs

I have a CategoryClass (Aggregate root) -> SubCategoryClass -> and now a relational entity (n-n). Category (root) 1->N SubCategory 1->N SubCategorySlotType (n-n) SlotType (root) My SubCategory only ...
2
votes
1answer
175 views

A problem with understanding aggregates and aggregate roots in Domain Driven Design (DDD)

I've stumbled upon a problem: "I can't split my domain models into aggregate roots". I'm a junior developer and novice at DDD. I really want to understand it, but sometimes it's really confusing. ...
1
vote
1answer
117 views

DDD Aggregate with Catalog Product

I'm new to DDD and I'm trying to figure out the aggregate root. I'm sure this question has been asked a million times. So I have : Products (thousands) Catalogs (hundreds) CatalogEntries that ...
0
votes
1answer
374 views

Confused about commands, domain events and external events in event sourcing

I'm a little confused about commands role in event sourcing distinction between domain and external events If my understanding is right a command represents an action initiated by an actor in terms ...
1
vote
1answer
130 views

DDD - how to model validation and enforce invariants that possibly resides in different aggregates

I have two models in my current design, student and group. Student and group are both aggregate roots. A student can be added to a group (method on group aggregate root), and it can be active for ...
1
vote
3answers
280 views

Domain Events, CQRS, and dependency resolution in handlers

Currently: ASP.NET Core 2.2. I've been doing quite an extensive research in this topic (Domain Driven Design used together with Clean Architecture): DDD: Where to place domain event handlers? And I'...
1
vote
1answer
69 views

DDD: Re-assign an entity from one aggregate to other

Let's pretend I have an 'Book' entity, that can contain many 'Chapter' entities, having both their own unique IDs. A chapter must belong to a book, it cannot exists on its own (ie: there is a required ...
0
votes
1answer
54 views

Should I have two identical classes in two different aggregate roots?

I have an application that is modifying some XML files. Two of the files have a similar structure, with similar business logic needed to be implemented on them. I've realized that there are some ...
0
votes
2answers
245 views

DDD: repository for a nested entity?

I have a AR called User, which has among other entities one called City. The way I assign a City to a User is: $user->addCity($city); The problem comes when a id is given at some Controller ...
0
votes
1answer
98 views

DDD - Handling temporary inconsistency when handling domain events

I realize that DDD advocates eventual consistency, thus allowing for a certain period of time in which the system might be inconsistent. Embracing eventual consistency, we can therefore model our ...
1
vote
3answers
312 views

How to validate command before executing on aggregate when validation needs to query data?

In a DDD designed application with CQRS principle how do we handle the case when a command needs to be validated before it is executed on an aggregate and the validation needs to query the existing ...
1
vote
1answer
191 views

How does a Repository delete removed Value Objects from the DB without ORM?

Let's say an Entity is composed of multiple ValueObjects. For instance, a wanderer might leave a few footprints behind. Imagine I load Wanderer from a repository and delete all footsteps north of the ...
2
votes
2answers
1k views

DDD - Domain events vs application events

I'm considering two types of notifications: Domain events used internally within a bounded context Application events used to exchange notification messages between bounded contexts Each aggregate ...
1
vote
1answer
284 views

DDD Relations between child entities / value objects

I'm new to DDD and trying to wrap my head around it by writing a prototype for an application (Core-Logic-Layer). My domain model looks like this atm. (I leaved out parts, that weren't necessary for ...
0
votes
1answer
61 views

Is changing the domain according to the user privilege on specific fields considered as anti-pattern?

Is changing the domain according to the user privilege on specific fields considered as anti-pattern? My case: I have Schedule Entity (aggregate root) like this: public class Schedule : Entity<...
1
vote
1answer
376 views

DDD - Aggregate Root get reference to another Aggregate Root

I have 3 ARs: Student Guardian Business Rule: Student should have at least 1 authorized Guardian Entities should not be in an invalid state right? Right now I enforced the invariant in my Student ...
1
vote
1answer
132 views

PHP: Domain model and aggregates

I am building an app that uses a client and a project entity. The clients can extend their profile over various screens in their account, like status, settings, etc. These data sets are saved in ...
2
votes
3answers
214 views

How can I aggregate this large data set to reduce the overhead of calculating the same values over and over?

So, we have a dashboard page where a lot of different values are aggregated and presented. These values are calculated based on roughly 500k data points and presents different index values based on ...
2
votes
2answers
259 views

DDD: deciding when to lean towards eventual vs transactional consistency

I am reading Vaughn Vernon's series of articles about effective aggregate design. On the subject of deciding between transactional vs eventual consistency, it states the following: Discussing this ...
1
vote
3answers
3k views

DDD: Is an aggregate root responsible for deleting its child entities from their repository?

I am developing a large software project using DDD (Domain-Driven Design). I have an entity that acts as an aggregate root, let's call it Root. This entity refers to a collection of child entities of ...
5
votes
1answer
960 views

DDD - How to avoid overlapping aggregate boundaries?

I recently started reading Evan's book about DDD, and I decided to try and apply some of the principles from that book on a bounded context of a project I've been working on. The context of interest ...
0
votes
1answer
177 views

How to transform one aggregate to another in DDD

Where I work we've got wallets with transactions (i.e. every transaction belongs to a single wallet). Currently we're working on an addition of transfers between wallets. As a part of this, a new ...
1
vote
1answer
188 views

Passing Meta info from Command through Aggregate to Event

I have a CQRS system in development that passes the Command to a CommandHandler, which gets an Aggregate from a Repository, and calls a method with the properties of the Command (converted to ...
3
votes
2answers
298 views

Can an aggregate only ever consume commands and produce events?

In domain driven design based on domain events, I have the impression that several sources pronounce the rule that aggregates consume commands and produce events process managers consume events and ...
0
votes
0answers
745 views

DDD - Does Many to many relationships mean two different aggregate roots?

I'm facing the following issue: I have a very simple aggregate root Product, and a product contains Image entities. Right now in code this relationship is expressed as a Many to One relationship like ...
1
vote
3answers
837 views

Applying DDD, is having multiple aggregates representing the same concept from a different view a good idea?

We're completely remodelling a system at the company for which I am currently working. We're applying DDD and for the very first time I have actually got someone on my team who has some prior ...
3
votes
2answers
532 views

DDD creating an aggregate in response of an event on another

I am looking at a scenario for creating an aggregate instance from a trigger an a different aggregate. I've incorporated some logic in my DDD and Event Sourcing with Onion architecture learning ...
0
votes
2answers
281 views

An aggregate without an aggregate root?

This is not a problem I am having in my problem domain. It is just a thought exercise. Say I have a simple calculator like this: public class Calculator { public IEnumerable<KeyValuePair<...
4
votes
4answers
5k views

DDD: Identifying aggregate root in a simple example application domain

I'm trying to read about DDD, and i'm struggling a bit trying to to identify aggregate roots. I wrote a really simple app to divide players into different teams inside a game. So my entities are ...
0
votes
1answer
198 views

AggregateRoot Class DDD Multiple entities

I couldn't find a specific answer to my question but how would I develop an AggregateRoot class for the following scenario. public class Root{ public int Id {get;set;} public IList<Child&...
4
votes
1answer
874 views

Using Event Sourced Aggregate Roots with the Specification Pattern

I have a Aggregate Roots that use the event sourcing technique of being built from a series of events in a Repository. This is all great for when I just need to manage change of state etc, but when I ...
1
vote
2answers
701 views

Can one Aggregate Root have multiple subtypes

I have a concept that I am struggling to design in a DDD CQRS manner, and I hope to find some insight. In the old days (before I knew DDD) I would have used simple inheritance, and that's how my mind ...
2
votes
0answers
388 views

Balance between aggregate boundaries and domain consistency in DDD

Designing an Aggregate and choosing an Aggregate Root getting tricky for me all the time especially when it comes to ensuring right transactional contexts and consistency constraints so I'm wondering ...
7
votes
1answer
1k views

Updating nested objects in DDD Aggregate by example: delegation or direct access from the root?

The example domain problem There is a student attendance tracking system that keeps records of student attendances of ExerciseGroups. Course is a top-level component, AR, describes a generic info ...
-2
votes
1answer
148 views

Filling in background information in terms of DDD

Recently, I asked about my difficulties in finding the boundaries of aggregates here and I recently reinterpreted it and rid it of business features and now it sounds like this: In many sources, ...
10
votes
2answers
1k views

How to design the aggregate boundaries?

I would like to write an application something like ecommerce. And you know that in similar applications products could have different properties and features. To simulate such an opportunity I've ...
4
votes
1answer
525 views

DDD - Domain Modelling association between aggregates

I have a bit of a mental block when trying to model my scenario whilst practicing DDD. The problem appears to be around 2 entities you would consider to be aggregate roots. I feel these aggregate ...
2
votes
2answers
2k views

DDD - Aggregate inheritance and repositories, how to correctly design this situation?

I'm working on a legacy warehouse system. There is one Aggregate root, Product which has its correspondent ProductRepository. Right now I have a new requirement that says the following: Some ...