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.

Filter by
Sorted by
Tagged with
2
votes
4answers
133 views

Migration from Anemic Models to Rich Models

I am looking into improving my overall application architecture and (I think) I understand the issues my Anemic Models are causing. Here is my current architecture: Controller with injected Service ...
2
votes
1answer
146 views

Applying Domain Driven Design - Model/Implementation

I'm quite new in the DDD-World and I'm just trying to figure out all the basics so please bear with me! I have the following Entities: - Datamodel - Object Types - Object Fields A datamodel can ...
2
votes
2answers
148 views

Multiple database system design

I am designing a few different systems that revolve around a core system used to manage users, groups, associations between users, group memberships, user profiles and some other things. System A ...
4
votes
3answers
143 views

Is a repository return a graph of entities violating SRP?

I'm working in this scenario Post entity has many Image entities. I also have repository to both entities: PostRepository ImageRepository Since this entities are tightly related, when I get a Post ...
1
vote
0answers
356 views

Authorization, permissions, and scoping resources in a microservice/DDD architecture

I'm building a microservice-based application (services according to DDD) and am about to implement authorization service. There are API gateways and UI applications that access backend servers, and ...
3
votes
1answer
106 views

DDD - Aggregate that changes “owner” mid-process

We're evaluating CQRS/ES for a high-volume subsystem in our app in order to take advantage of distributed systems and ensure uptime. This is my team's first time implementing this architecture, and I'...
1
vote
2answers
99 views

DDD aggregates, entities, REST and how they all fit together

I'm trying to apply DDD principles to an application that has a REST API in front and is backed by an SQL storage. Here's the entity structure I have come up with so far: Client: 1 ---- * Contract: ...
2
votes
3answers
348 views

Aren't Domain Driven Design/“hexagonal architecture” with real world constraints and the insistence on “non anemic model” contradictory?

DDD/"hexagonal architecture" insist on separating the domain, aka model, from infrastructure requirements. This looks clean and logical until you realize that storing your domain object in memory ...
1
vote
1answer
210 views

Multiple APIs v One API

Is it normal to have a bounded context spread accross multiple APIs or should there really be one API per bounded context? I am trying to understand if I can use the Scatter Gatherer pattern (https:...
1
vote
1answer
191 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 ...
0
votes
1answer
125 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
359 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
5answers
214 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
170 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
81 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 ...
1
vote
2answers
540 views

DDD - Referencing Aggregate Root of other bounded 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
134 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
131 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
226 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
201 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
88 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
194 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
75 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
197 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 ...
9
votes
5answers
2k 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
455 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
323 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
55 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
52 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
422 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
87 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
85 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 ...
1
vote
3answers
353 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
315 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
105 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
48 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
75 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 ...
4
votes
2answers
2k 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
215 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
71 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
257 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
276 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
104 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
197 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
3answers
168 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(...
1
vote
2answers
116 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
161 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 ...
2
votes
1answer
236 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
256 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 ...