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.

Filter by
Sorted by
Tagged with
55 votes
6 answers
24k views

Are DDD Aggregates really a good idea in a Web Application?

I'm diving in to Domain Driven Design and some of the concepts i'm coming across make a lot of sense on the surface, but when I think about them more I have to wonder if that's really a good idea. ...
user avatar
11 votes
3 answers
4k views

Confusion about the meaning of the word aggregate in domain driven design

In a discussion about domain driven design I have learned the different people seem to think of different things when using the word aggregate. The main difficulty is that some people use the word ...
user avatar
11 votes
2 answers
3k 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 ...
user avatar
  • 133
9 votes
2 answers
8k 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 ...
user avatar
8 votes
4 answers
11k 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 ...
user avatar
  • 338
8 votes
3 answers
5k views

DDD - Aggregate Roots - Dealing with Efficiency and Concurrency

First off, I'll admit that I'm a newbie to DDD and need to read the "blue book". I'm building a system that has an AggregateRoot of type "Match". Each Match can have a collection of "Votes" and also ...
user avatar
  • 334
8 votes
3 answers
6k views

Can there be multiple aggregates for the same concept?

Say I have the concept of a User; a very basic structure in reality. If the business requires that an aspect of the software needs to display all related 'Posts' for example, how should that be ...
user avatar
8 votes
1 answer
4k 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 ...
user avatar
  • 431
7 votes
3 answers
2k views

DDD - operation on one aggregate that creates another aggregate

Let's say I am designing a TODO application and therefore have an aggregate root called Task. The business requires to keep a list of TaskLogEvent that provides them with a history of how the task ...
user avatar
7 votes
3 answers
2k 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 ...
user avatar
  • 431
6 votes
4 answers
9k views

Domain driven design, can two aggregates have the same root?

For the purpose of separating different functionality into different classes, I have two following Aggregates: ActiveEmployee AssignTask () ReassignManager () Deactivate (string reason) ...
user avatar
  • 163
6 votes
1 answer
1k views

How can I avoid a cross aggregate transaction?

Consider this simplified example: In an online ticket sale website, tickets have variable prices that change over time. User searches for tickets. Once he finds a ticket he wants, clicks "Buy" and ...
user avatar
6 votes
1 answer
2k 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 ...
user avatar
6 votes
2 answers
2k views

Recreating complex aggregates from a persistance source

I'm building a web application with C#, and I have an aggregate root which has several entities and value objects. Then I have a repository object which persists the aggregate to the database (I'm ...
user avatar
6 votes
1 answer
1k views

Event sourcing - applying events before change is done?

So, I have Aggregate root that has some sub-entities with some sub-value objects (classic DDD design). I wanted also to use Event sourcing in Aggregate design. In AppService layer I receive Command, ...
user avatar
6 votes
2 answers
6k views

how to paginate and combine results that come from different sources sorted

I have the following scenario: I have a user that needs to see some news feeds from different sites and I want to paginate them and sort them by date. The problem is I don't understand how to do ...
user avatar
4 votes
6 answers
907 views

UML aggregation: how can the "whole" exist without its "parts"?

I understand aggregation is a "whole/part" relationship, where the "parent" class is the whole and the "child" class is the part (and this is unidirectional), and that each class exist independently (...
user avatar
  • 373
4 votes
3 answers
5k 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 Products ...
user avatar
4 votes
2 answers
1k 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 ...
user avatar
  • 321
4 votes
3 answers
1k 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 ...
user avatar
  • 2,715
4 votes
1 answer
4k views

Rest API calls with side effects on other resources

Let's say I have a mobile app, android/iOS and a java Spring back end. Given the mobile connectivity, the number of network round trips must be limited, ideally, 1 or less per screen. Now, let's say ...
user avatar
  • 641
4 votes
2 answers
716 views

In DDD Aggregate + Event Sourcing, do Events happen before or after state changes?

Part of the Aggregate + Event Sourcing (A+ES) methodology feels uncomfortable. Why does it feel uncomfortable? (As I've read from other questions and the book itself, it's a new-ish way of thinking, ...
user avatar
  • 2,341
4 votes
3 answers
9k 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 ...
user avatar
  • 191
4 votes
1 answer
1k 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 ...
user avatar
4 votes
1 answer
1k views

DDD: are objects that represent "aggregate roots" must be unique (singleton-like)

I'm developing my first application using DDD and event sourcing. From what I understand, aggregate encapsulates specific domain functionality with one or more associated invariants. The invariants ...
user avatar
  • 151
4 votes
1 answer
1k views

Aggregate root with many fields

I'm struggling with this problem for a long time now. Lets say that I'm trying to model some business that has Customers, Companies, Contracts, Invoices etc. All of them looks like good candidate for ...
user avatar
  • 163
4 votes
2 answers
3k views

Domain Driven Design - Updating and persisting aggregates

I'm trying to wrap my head around the best possible solution in the following situation: When updating part of an aggregate, could be any part of the aggregate so either the root or any other entity, ...
user avatar
4 votes
1 answer
3k 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 ...
user avatar
4 votes
1 answer
956 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 ...
user avatar
  • 249
4 votes
1 answer
2k views

DDD – duplicity between Aggregates – should I use one table?

I understand that there exists duplicity of data between Bounded Contexts. The thing is that I'm not really sure about duplicity of data between Aggregate roots. Example: I have product in Product ...
user avatar
4 votes
2 answers
458 views

Domain Events Grouping/Buffering

Suppose I have 3 domain events, Event1 Event2 and Event3. When command arrives at my Service Layer, I can rise 2 commands at the same time - e.g. Event1 and Event2. One Class has event listener for ...
user avatar
4 votes
4 answers
3k views

Can an aggregate root hold references of members of another aggregate root?

I know that outside of aggregates I can't change anything inside an aggregate without passing by his root. That said I would like to know if an aggregate root can hold references of members (objects ...
user avatar
  • 539
3 votes
2 answers
368 views

Is accessing lower tier members of an aggregate to perform an operation bad practice?

I am currently building a small project that is supposed to keep track of recipes. Each recipe has a bunch of information, including a rating for said recipe. Since the rating has some additional ...
user avatar
3 votes
2 answers
6k views

Collection vs data structure vs aggregate

I know three terms that have to do with storing objects or data. I'm not sure I understand the exact differences between the terms. Please confirm if what I'm about to write is accurate. A data ...
user avatar
  • 20.7k
3 votes
2 answers
4k views

Handling aggregate root with deep object hierarchy

What is the correct way to apply commands to objects deep within the model hierarchy? Given the following model: public class Picture : AggregateRoot { private string title; private List<...
user avatar
  • 141
3 votes
1 answer
1k views

How does the Aggregate Root concept and the Repository Pattern solve DRY in database operations?

If I have ten classes, and they all need CRUD operations, how does an Aggregate Root and the Repository Pattern solve me having to write lots of boilerplate code (the DRY)? Take the example of a ...
user avatar
  • 3,629
3 votes
2 answers
332 views

Abstract Factory: Can Client Class have an aggregation with the Factory?

After searching for some Abstract Factory examples using modern programming languages, I have some dillemas about the sensu lato of conceptual UML schema of Abstract, more specificly about the Client (...
user avatar
  • 243
3 votes
3 answers
5k views

Is this an example of a composition or aggregation? [duplicate]

Composition and aggregation both are confusion to me. Does my code sample below indicate composition or aggregation? class A { public static function getData($id) { //something } ...
user avatar
3 votes
2 answers
1k views

Proper way to interact with child entities through aggregate root

In a DDD implementation, I am trying to design my domain model and the way to properly interact with child entities of an Aggregate through the Aggregate root. Imagine the following two classes in an ...
user avatar
3 votes
3 answers
670 views

Importance of loading/saving complete aggregates at once in DDD

In the context of a web application where we handle only one command per request in a stateless fashion, do we always have to load/save aggregates as one atomic unit? Why is it recommended not to ...
user avatar
  • 197
3 votes
2 answers
991 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 ...
user avatar
  • 249
3 votes
1 answer
106 views

How to model ordering of Aggregate Roots?

Let's imagine a simple domain model: // aggregate root class TaskList( id: Long, name: String ) // aggregate root class Task( id: Long, taskListId: Long, name: String, dueDate: ...
user avatar
  • 796
3 votes
2 answers
208 views

Enforcing aggregate rules in purchase management domain

I'm having problems defining the aggregate boundaries (and maybe even the aggregate root) to enforce the transactional consistency rule. Let me first describe the problem domain. In our domain we ...
user avatar
3 votes
0 answers
1k views

DDD problem with aggregate design (users, authentication)

We're having a bounded context dealing with payments. I'm trying to model case, where Merchant can create another merchant and inherit some of its properties in this case: users that are needed for ...
user avatar
  • 217
2 votes
3 answers
381 views

Aggregate roots always have to be "complete"?

Lets think about the most common Aggregate Root example: Order and OrderItems (or OrderLines). So I want a useCase called UpdateOrderItem. Given a OrderItemID and a complete OrderItemDTO in the ...
user avatar
2 votes
1 answer
201 views

Which layer should convert timezones given querying on aggregate tables?

I'm running a Django application service with an API that feeds to a javascript frontend. The data is specifically for charts and graphs, so the data that is returned is a fairly large json with every ...
user avatar
  • 2,629
2 votes
1 answer
202 views

Reusing aggregate root key across bounded contexts?

As the question states, is this bad practice? I have a User aggregate root in the bounded context of Identity for authenticating the user. In this bounded contexts I have fields for the User related ...
user avatar
  • 49
2 votes
2 answers
197 views

Maintaining referential integrity between Aggregate Roots

In his book "Implementing Domain-Driven Design" Vaughn Vernon suggests to reference aggregate roots only by ID. I see the following advantages of this approach: It is clear where the ...
user avatar
  • 796
2 votes
3 answers
2k 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'...
user avatar
  • 275
2 votes
1 answer
1k views

Sharing of event source stream between aggregates

I have a question related to cqrs + event sourcing. I have two aggregate roots (AR1 and AR2). When AR1 received a command/event it will be recreated from previous event sourcing stream from repository ...
user avatar