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
Make your voice heard. Take the 2019 Developer Survey now

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.

1
vote
1answer
56 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:...
41
votes
11answers
20k views

Best practice or design patterns for retrieval of data for reporting and dashboards in a domain-rich application

First, I want to say this seems to be a neglected question/area, so if this question needs improvement, help me make this a great question that can benefit others! I'm looking for advice and help from ...
0
votes
5answers
192 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 { ...
1
vote
1answer
29 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
60 views

Event Store deals with Domain events or representation of domain events

I am starting a new DDD architecture and I have a dilemma with Domain Events and the way they're retrieved and stored in an EventStore database. First of all, should the EventStore live in the Domain ...
0
votes
1answer
89 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
59 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
1answer
120 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; //...
19
votes
6answers
18k views

Is it good practice to use entity objects as data transfer objects?

I am wondering because if it is, why does Entity Framework not offer logic to create a new object with the same properties to transfer data between layers? I use the entity objects that I generate ...
0
votes
2answers
69 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) ...
0
votes
1answer
197 views

Should I add XML comments in DTO models or entity models

I have 2 models, DTOs and database models (entities) that map to the database. I usually put XML comments above the properties to describe what are they for. class MyEntity { /// <summary> ...
-1
votes
1answer
58 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
344 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 ...
-3
votes
0answers
33 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 ...
0
votes
2answers
94 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. ...
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
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 ...
2
votes
1answer
298 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 ...
0
votes
2answers
81 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 ...
1
vote
3answers
139 views

Event Sourcing details in Domain Model

I have been studying DDD and have been experimenting with Event Sourcing as a storage mechanism. Prior to this (mostly CRUD-style applications with anemic data models stored in relational DBs), a "...
0
votes
2answers
165 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
3answers
130 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 ...
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 ...
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 ...
3
votes
2answers
388 views

Domain Driven Design approach for game

I'm working on a realtime multiplayer game project. There are entities like Player, Game, Flag etc. And bunch of it's behaviours like PlayerRespawnBehaviour, PlayerWalkBehaviour, ...
1
vote
2answers
85 views

get aggregate id based on its data in it

I have an aggregate root called SizeRangeAggregate which holds the range of size of clothing piece dimension and price for that range. I created an post rest API which create new SizeRangeAggregate. ...
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 ...
1
vote
2answers
251 views

DDD - How to do informative validation (specifically on entity creation)?

For my domain entities currently, all validation errors cause exceptions to be thrown. I don't like this as it doesn't allow me to compile all validation errors before exiting a method. I'd like to ...
0
votes
2answers
69 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 ...
3
votes
2answers
235 views

Why does BDD advise an outward in approach to testing?

I am trying to decide whether BDD is suitable for my project or not. I was reading about BDD here: https://en.wikipedia.org/wiki/Behavior-driven_development and here: https://agilewarrior.wordpress....
1
vote
1answer
209 views

Domain driven design - factory with cross-cutting concerns

I was recently tasked with creating a factory that processes webhook events. Any authorized application in the solution (1 app per domain) can post any meaningful payload and as long as the event's ...
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 ...
2
votes
2answers
76 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
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
98 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
71 views

Can a bounded context be made up of other bounded contexts?

I am arguing with co worker that a bounded context can be made of other bounded contexts. My example is: I am having a tour context made out of flight bounded context hotel bounded context visa ...
1
vote
3answers
93 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
352 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
50 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
1answer
295 views

DDD: Should create domain model for complex application layer?

I'm midway through Eric Evans' DDD book but don't think this question would be answered in the book. If an application has its own complicated concepts different from the underlying domain, can we ...
2
votes
1answer
588 views

Use Spring JPA entities as domain model entities in DDD?

Is good idea to use Spring JPA entity classes from my data model as entities for domain model in domain driven design? Or should it be mapped into separated ddd entities. What is best practice / ...
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 ...
3
votes
1answer
211 views

Domain Events Groupping/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 ...
0
votes
3answers
154 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
1answer
44 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 ...
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 ...