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 [domain-driven-design]

Domain-driven design (DDD) is an approach to develop software for complex needs by connecting the implementation to an evolving model.

0
votes
1answer
16 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
votes
1answer
77 views

What is the full value of the CQS principle in a system that doesn't implement the CQRS pattern?

I'm having trouble grasping the value proposition of the "command" half of the CQS principle in a system that doesn't implement command query responsibility segregation. The CQS principle states that ...
1
vote
3answers
57 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'...
0
votes
4answers
121 views

Design Pattern for object that asks questions of another object

I'm looking for a design pattern that might work for this class I am working with. This main class is an entity using Domain Driven Design. public class TimeCard() : ITimeCardHeader { ...
0
votes
2answers
68 views

Domain Driven Design Modelling Organization -> User

Relatively new to Domain Driven Design i decided to try it out in an saas app currently under development/refactoring. I've refactored the identity part out to it's own context (class library in .net) ...
-1
votes
1answer
56 views

Patterns for loading related objects in memory (without an ORM)

I am using ADO.NET to read a bunch of data from the database into in-memory objects. This is my domain model: // Question.cs public class Question { public int ID { get; set; } public ...
-3
votes
0answers
32 views

What is the difference between aggregate and domain [duplicate]

I'm studying Domain driven design (DDD), reading many articles, but reading " Domain driven" I never saw what is the Domain properly? What it is it? Please, show me at the picture: My question is ...
1
vote
2answers
339 views

DDD - Referencing Aggregate Root of other bouned context?

I'm building a personal project, as an introduction to DDD, I'm doing a little bit of analysis and can't get my head around it. My ERD looks as follows: To go over it, as an admin you can setup a ...
0
votes
2answers
92 views

What is Granularity?

I am reading Eric Evan's Domain Driven Design, and I encountered this concept on p108. I am having a hard time grasping the concept, in spite of the explanations mentioned on the pages 107 and 108. ...
0
votes
1answer
117 views

Can the write database have different fields to the read database?

I am trying to learn CQRS in my spare time. Say I have a class like this: public class Person { private Guid Id {get; set;} private Guid Name {get; set;} private List<Order> orders; //...
-1
votes
1answer
36 views

DDD Including DB Id in domain entity

According to the book, The domain layer should be isolated. In domain entity, you should avoid adding a property represents database PK (usually identity surrogate column called ID). There is no ...
0
votes
2answers
79 views

Anemic Domain Model, CQRS, command bus

Considering this pattern is used to support CQRS message bus, examples are buslane Python or MessageBus PHP It uses commands to change the domain model, and publishes domain events This looks great ...
-1
votes
1answer
85 views

add new class that implement base interface but need one more parameter

I have few strategy class that calculate ranking. Those class implements interface with method scoreUpdates. Method scoreUpdates take two parameters( winners and lossers). Now i need add new ...
0
votes
2answers
163 views

How compatible are data science notebooks with clean architecture?

Clean architecture decouples an app's core from the presentation/UI layer. The UI is just a plugin, replaceable (eg, web-based to desktop) without impacting the core. Many data science apps mix code,...
1
vote
1answer
34 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
2answers
88 views

DDD enforcing business rules

New to DDD I have a simple case a I would like to model using DDD approach 2 entities Student and Course Relevant property for Student are StudentId and Budget Relevant property for Course are ...
1
vote
3answers
127 views

Pitfalls of Domain-Driven Design with Entity Framework

A lot of tutorials on DDD I studied are mostly covering theory. They all have rudimentary code examples (Pluralsight and similar). On the web there are also attempts by a few people to create ...
0
votes
2answers
67 views

Multiple processes in single microservice

We have a microservices architecture very similar to the architecture described here Obviously, it's a simplified diagram of a real system. In our case, we have a requirement to perform background ...
2
votes
2answers
104 views

DDD - how to handle growing entity collection

Say we have an imaginary system managing purchases made by customers, and there are the following business rules: You can only buy a product if you have enough money on your pre-paid account You can ...
27
votes
2answers
3k views

Is a Unit test considered brittle if it fails when the business logic changes?

Please see the code below; it tests to see if a person with Gender of female is eligible for offer1: [Fact] public void ReturnsFalseWhenGivenAPersonWithAGenderOfFemale() { var personId = Guid....
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
1answer
48 views

Domain services structuring

Currently i am handling placing my services by their action type like App Services Storage Payments Providers Gateways IpnHandler But i felt like whenever our payment providers are growing i ...
0
votes
0answers
91 views

EF Core Many to Many Relationship

I am thinking about using Entity Framework Core in a new project. The project has a many to many relationship. Entity framework Core does not allow shadow state entities as described here: https://...
0
votes
2answers
49 views

Reuse domain entity logic

Usually the domain logic should be contained in the domain entity, rather than being put in specialised external classes called from the entity. This is good to prevent that somebody comes later, ...
2
votes
2answers
77 views

Multiple usages of same Entity

Currently we are designing a system where a user can comment on multiple subjects. Subjects can be a picture, a post, etc. A comment should be editable and deletable. It would just contain text (for ...
0
votes
3answers
153 views

Business logic contained inside JSON

I have recently looked at some Web APIs provided by well known companies' e.g. this one by HSBC: https://developer.hsbc.com/swagger-index.html#!/Products_Commercial_Credit_Cards/...
1
vote
2answers
85 views

How to deal with an event if the domain aggregate was not yet persisted?

When I call paid() on my aggregate it sets all the properties internally that need to be changed based on this action. But at this time the change has not been saved to the DB, so I can't reliably ...
1
vote
1answer
43 views

Paging params - domain repository interface

I usually define my repository interfaces at Domain Layer with DDD. Given that the UI needs to display some paged data I thought that adding params such as currentPage, pageSize, and define a model ...
0
votes
2answers
44 views

Methods taking parameter of Collection should filter the collection themselves or be passed a filtered collection?

Say I have this reasonable contrived situation: public class Toast { public bool Toasted { get; set; } public int MinutesToHeat { get; set;} } public class Toaster ...
1
vote
1answer
62 views

Too strong of coupling between aggregate roots?

In an effort to save this question, I have re-written it. The original question was regarding how to associate aggregate roots. I have re-factored the code slightly but believe this may couple the ...
1
vote
2answers
119 views

Should CQRS Command perform a Query?

I have Customer, Order, and Product Aggregate Roots... When the order is created, it takes in a Customer and a List<Sales.Items>. It looks something like: public class Order { public static ...
1
vote
1answer
76 views

How to handle a many to many relationship with an ORM mapped to a Domain Model when there are no technical constraints?

Domain Driven Design states that you should have a domain model, which reflects the ubiquitious language used by the domain experts. When using ORMs and many to many relationships I am use to doing ...
0
votes
1answer
28 views

CQRS across bounded contexts to generate reports with possible business logic

Where do you draw the line for how much logic can go in your read models? For example, we have 2 BCs: Inventory and Sales. We need to generate reports regarding inventory levels on specific dates: ...
0
votes
2answers
95 views

DDD - view-only aggregate roots, building DTO and a lazy loading problem

Suppose I am developing a RSS system (following DDD practises). Users have accounts. Accounts have feeds. Feeds have articles. Account, Feed and Article are my aggregate roots as well as ...
0
votes
2answers
67 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
62 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
1answer
52 views

Cross-aggregate operations, use domain service or domain events?

I'm refactoring a settlements module in a large healthcare application. I'm trying to follow DDD. Let me give you a short and simplified description of the refactored code: A patient has an ...
2
votes
2answers
75 views

Define multiple DDD events or just one XXXChanged event when using CQRS?

Is it preferable to define a single 'container event' like below: trait UserStatus case object Active extends UserStatus case object Inactive extends UserStatus case class UserStatusChanged(...
0
votes
2answers
61 views

Void Or Other Result In DDD Operation

If this is basic question sorry , but anyway it is a question . i am doing domain driven design , i know about RootAggreegate , Anemic model , Rich Model , Domain Services , and ... but still when ...
1
vote
0answers
59 views

Domain Service vs Domain Events

What is the difference between using domain services and domain events? The thing I can see is that domain events allow you to further decouple your domain model and get away from using domain ...
0
votes
1answer
51 views

Referencing entity inside aggregate by local ID

How do you properly reference an entity inside an aggregate? For example, by the index of a list (doesn't seem smart if you re-order the list); a GUID (thought it was supposed to be local?); or some ...
1
vote
2answers
177 views

May Domain Events handlers lead to new events?

I want to understand the consequences of allowing handlers to be direct or indirect source of new domain events. In all examples I see in the literature Domain Events are usually published by ...
0
votes
1answer
207 views

DDD - Factory or Service?

I'm new to DDD, and I'm confused at the very start of my DDD project. To setup a context, I'm building the user management part of my app, so I'm building my Account entity, which contains an Id, a ...
2
votes
1answer
293 views

Ending up with too many services in DDD

I'm working on a project at the moment and I'm using this project to try and apply DDD. However, there are parts of my implementation that I just can't get my head around or don't feel right. I'll try ...
3
votes
1answer
52 views

How do I migrate part of a business process to DDD?

I am quite new to DDD, but I am currently working on a system which has a payroll element to it. I have a requirement to send payslips to an external system when they are created. Currently the ...
0
votes
1answer
207 views

Onion architecture applied to an .NET application

I am trying to figure out how to translate the onion architecture into an ASP.NET Core WebAPI solution, this is what I ended up with: Let's say I have an application that takes a file path / uri into ...
0
votes
2answers
135 views

Where should permissions be stored in a micro services architecture

We are currently in the process of building a service (a REST API) which is called on by our primary application. The primary application contains a users/permissions/roles set up which is used to ...
0
votes
5answers
223 views

Is using overly specific names for variable/class/component names a good or bad practice?

Let assume that we have a system in which the users can chat with each other and we are working on the backend. We can name the service which fetches the chats in one of the following ways: ...
1
vote
3answers
91 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 ...
0
votes
2answers
96 views

Lookup code tables in DDD

I'm curious on the best way to handle lookup-type codes that can be shared across bounded contexts. For instance, state codes, or business-specific type codes that might be used in more than one ...