Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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
2answers
42 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
33 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
48 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
66 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
61 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
90 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
93 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 ...
0
votes
2answers
398 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
107 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
59 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
250 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
60 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
209 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 ...
0
votes
0answers
32 views

Aggregate in memory and update records with workers in queue

Imagine a 'views' column on database table. Each user that views a page like a video or similar run a query to database to increment the field value. To reduce the database writes, I want to ...
3
votes
2answers
154 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
2k 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 ...
2
votes
1answer
555 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
108 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
118 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
186 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
473 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
595 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
394 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
225 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<...
2
votes
4answers
3k 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
152 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
653 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
563 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
233 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
139 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
939 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
423 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
1k 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 ...
0
votes
1answer
552 views

DDD integrating aggregate root with open host service (OHS)

Here is the case: according to ubiquitous language - payment can be sent for processing to payment gateway (which is in different bounded context integrated via ACL (anti-corruption layer) + OHS/PL) ...
1
vote
0answers
135 views

Collecting sports data from many sources in many formats

I'm trying to solve a problem that exists for a sport. The sport is fragmented into many federations, and each federation is completely isolated from other federations. The sport is the same for each ...
2
votes
0answers
447 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 ...
3
votes
2answers
1k 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<...
4
votes
3answers
2k 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 ...
0
votes
2answers
419 views

DDD: How to avoid breaking encapsulation and leaking technical concerns to the domain during model rehydration?

When applying DDD principles in Ruby, I feel that Active Record pattern ends up polluting the domain model, while I'm not sure how to implement JSON deserialization without breaking encapsulation. ...
2
votes
1answer
102 views

Should this behavior be modeled as an entity or domain service?

Imagine that you're modeling SE (or SO) on DDD. You decided to implement the "board" as an aggregate root. So the board has the method AddNewQuestion(string question). There are business rules that ...
6
votes
1answer
250 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 ...
1
vote
1answer
351 views

How to effectively store aggregates in actor model

I'm struggling with aggregates in actor model (akka) and how to store their state. I wonder what role does repository stands for in actor model in DDD. I have a situation, where my aggregate root ...
0
votes
2answers
154 views

Should the Application Service in DDD use references to non-root entities and value objects inside an aggregate?

I understand that objects external to an aggregate shouldn't hold references to entities and value objects belonging to the aggregate. My question if this also applies to the Application Service that ...
2
votes
2answers
154 views

How should I approach instantiating a UUID from another aggregate

Forgive me if this is a truly naive question, I can't find an answer anywhere (which makes me think it is maybe silly and naive). If I am to hold a reference to an aggregate inside another, I of ...
5
votes
1answer
450 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 ...
3
votes
1answer
444 views

How to query a child object within an aggregate root on demand?

I'm learning DDD. For a practice, I'm trying to convert my own app to DDD aggregates. What I understand so far on aggregate. Aggregate defines transactional boundary Design aggregate as small as ...
0
votes
1answer
482 views

CQRS - Passing aggregate root as argument

So, I have following code: public class CQRSQuestion { public static void main(String[] args) { //received command for algorithm run AlgorithmAR algorithmAR = new AlgorithmAR(...
1
vote
1answer
559 views

Aggregate relationships in Domain Driven Design

I have a question related to relationships between aggregates in Domain Driven Design. I have the following situation: I have an aggregate (questionnaire) which has some children (questions). The ...
4
votes
1answer
803 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 ...