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.

131 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
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
1 answer
448 views

DDD: Type hierarchy of entities' property

Say I have an Delivery class which should have a Destination property (among many others). Destination can be an Address (country, city, address line, post code) or a Port (international code, name). ...
user avatar
  • 161
5 votes
2 answers
782 views

Persistent Model to Domain Model mapping without exposing domain object's attributes

I know this is a common question, but I haven't found another that solves my doubts. Usually, if the project is small, I've persistence annotations in the same object that represents the domain ...
user avatar
  • 201
4 votes
0 answers
448 views

Best practice to reuse use cases in a clean architecture

Imagine a "clean architecture" in which you have two use cases. One of them is CreateCustomerHandler, and the other SignUpCustomerByGoogleAuthHandler. So, the ...
user avatar
  • 149
4 votes
1 answer
465 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 ...
user avatar
  • 49
4 votes
0 answers
2k views

DDD directory structure for MVC app

As a means of learning and gaining some experience with domain-driven design, I'm restructuring/refactoring an old application written in PHP which utilizes the Laravel 5.1 framework. Below is a mock-...
user avatar
  • 149
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
1 answer
1k views

Design for syncing data from remote API

I am trying to find a robust and correct solution for syncing data from different sources to my local relational database. I have different sources of data for eg: CSV, REST API and probably network ...
user avatar
  • 2,106
3 votes
1 answer
694 views

DDD / Onion architecture in JavaScript

One reason I like .NET is because the 'solutions' and 'projects' lends themselves to good architecture. Good architecture makes it easy to follow the happy path of Domain-Driven Design. I've fallen ...
user avatar
  • 2,050
3 votes
0 answers
115 views

How should domain model entities expose information about the current state of their properties?

I'm new to DDD, so please bear with me. I am trying to design a domain model around an extremely large and complex existing system, where most of the current "domain" logic is either in the UI or in ...
user avatar
  • 157
3 votes
0 answers
47 views

Can the read api receive events that the write api does not receive or raise?

Say I have a read API and a write API: MyApp.Write.api MyApp.Read.api Both API's handle integration events from other apis/microservices. Say I had certain integration events that only need to be ...
user avatar
  • 6,855
3 votes
0 answers
861 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 ...
user avatar
  • 199
3 votes
3 answers
1k 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(...
user avatar
  • 39
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
3 votes
0 answers
378 views

Examples for "serverless" Java service for AWS Lambda

Doesn anybody have practical experience with implementing a (micro)service based on AWS Lambda? My team is currently working on an MVP. We started with a monolith and that has worked very well. It's ...
user avatar
  • 489
3 votes
0 answers
533 views

Understand the service term in DDD and matching class diagram

I m trying to learn how to make my code better. This way, I try to learn some books and understand them. I m having some troubles dealing with Domain Objects. From the first year of my IT school, I'...
user avatar
  • 1,381
3 votes
0 answers
713 views

How to implement DDD in a distributed application with NHibernate?

I have an ASP.NET MVC web site working in this way: (In the controller) var user = _applicationService.GetUserById(1); user.ChangeEmail("mynemail@somewhere.com"); user.ChangeAddress("my new street", ...
user avatar
2 votes
3 answers
341 views

How to model 1 to many relationships in DDD (Domain Driven Design)

I think I am struggling to model a relationship between 2 entities. I am trying to do so in a way that promotes DDD and captures business semantics. The following is my business context: I am ...
user avatar
  • 147
2 votes
2 answers
216 views

Exposing methods for polymorphic children from the aggregate root

Consider the following fictitious toy example: There is an aggregate root DayChecklist that holds a list of Tasks planned for the day: class DayChecklist { String id; DateTime today; ... ...
user avatar
  • 87
2 votes
1 answer
227 views

Microservices: Is the Saga Pattern correctly applied here?

I'm trying to understand and learn how to build microservice messages the best and came up with this task for myself: Services given: Accounts Service Token Service Email Service When a user ...
user avatar
  • 461
2 votes
0 answers
397 views

How to retrieve login token from repository in network layer? Domain Driven Design - DDD

I am trying to come up with a design for an application I am working on. Here is a basic picture of what I am looking to do. Everything up to the Data Layer is totally fine but the Data Layer makes ...
user avatar
2 votes
0 answers
664 views

Product, Category, Attributes modelling in DDD

I'm trying to model online shop catalog using Domain Driven Design. There are three main concepts I have right now: Product, Category, Attribute. Attribute is a characteristic of a product. For ...
user avatar
2 votes
0 answers
465 views

How to achieve both: clean (hexagonal) architecture with JPA goodies?

How do I achieve two things at the same time writing Java Spring Application: Clean Architecture JPA goodies (@Transactional, Optimistic Locking, dirty checking, etc.) I like the idea of database/...
user avatar
2 votes
0 answers
310 views

DDD - Getting access to user email from different domains

Let's assume I was building a collaborative document editing platform ala Google Docs. Collaborators work together on a Document. A Collaborator must be a user of the platform. There's a Comment ...
user avatar
  • 291
2 votes
0 answers
198 views

DDD - Translating Ubiquitous Language Vocabulary Across Bounded Contexts

One of the guidelines around building ubiquitous languages is that there should be one per bounded context. In a domain that has more than one bounded context, and therefore more than one ubiquitous ...
user avatar
2 votes
2 answers
278 views

Can a query handler (not repository) access a web service?

Say I have the following class, which maps to a database table: public class Person { public Guid Id {get; set; } public string Name {get; set; } public DateTime DateOfBirth {get; set; } ...
user avatar
  • 6,855
2 votes
0 answers
200 views

UI syncing in case of bulk operation api

In a CQRS system, the convention that we follow is we render the detail view of an aggregate(i.e getById) using the write model and views containing multiple aggregates(like a dashboard) using read ...
user avatar
2 votes
0 answers
314 views

How to design a sync api exposed to third party which involves a business transaction across aggregates?

Business Domain In the Sales domain, I have 3 entities - Lead, Contact and Opportunity. A lead is injected into the system from many sources and nurtured. If it is a prospect then it is converted ...
user avatar
2 votes
0 answers
227 views

CQRS "private" command

In CQRS, if a saga (or more precisely a process manager according to the CQRS Journey book) sends out a new command to change aggregates how can I ensure that this command is not possible to send from ...
user avatar
  • 561
1 vote
0 answers
86 views

(How) should I handle a consistent but unwanted aggregate state?

It's clear that an entity should never be in an inconsistent state; if a change would violate an invariant, a domain object should reject the change. But what if it's left in a valid, but ...
user avatar
1 vote
2 answers
146 views

Should the Use Case be responsible for transforming its primitive parameters into typed data for the Entity to use?

I'm building a Use Case for creating blog posts, this Use Case has its own "DTO", which is basically a parameter object with only primitive data, as follows: Use Case's DTO (Parameter Object)...
user avatar
1 vote
1 answer
281 views

Can Domain Services publish Domain Events on multi-aggregate operations?

I'm in a scenario where, when a certain command is applied on an aggregate, I have to change the state of the aggregate itself if ALL related aggregates are in the same state, then notify the world ...
user avatar
1 vote
0 answers
114 views

Where does a Process Manager live with a Hexagonal/Ports and Adapters Architecture?

Context: I initially asked this question. I lacked some understanding and phrasing to ask the actual question I wanted to ask. The answer though helped me understand the friction points a bit better ...
user avatar
  • 2,341
1 vote
0 answers
35 views

Managing the output rate for a queue triggered service

I have a service which is triggered by messages from three queues (which are populated by different topics), and writes the processed results to another system (say DB service) synchronously. The ...
user avatar
  • 19
1 vote
0 answers
177 views

Domain Driven Design Exercise

I recently found out about Domain Driven Design and I liked it. However, it is quite overwhelming and requires quite of expertise to get it right. For this reason, I wanted to try to model a simple ...
user avatar
  • 149
1 vote
0 answers
44 views

Specifications Pattern crossing bounded context - Domain Driven Design

I'm trying to understand and implement with good practice the Specification Pattern within my domain driven design project. I have few questions: For example: verifying that a customer is subscribed ...
user avatar
1 vote
0 answers
219 views

DDD - Entity is shared by multiple Aggregates

i wonder what is the correct solution to ensuring consistency of a shared aggregate? Problem statement I try to model the registration at an event with reserved (and limited) seats (like shopping cart)...
user avatar
1 vote
0 answers
49 views

DDD - Aggregate holding logic of child entity vs using child entity repository

I'm trying to come up with a DDD solution. Let's say we have two entities: User and Post and User is a root aggregate. User { List<Post> posts; public List<Post> getPosts() { ...
user avatar
  • 11
1 vote
0 answers
51 views

Does my ASP.NET architecture implement DDD in a safe and future proof way?

I'm very new to DDD and sometimes confused by it because many people inside the DDD community tend to have very different approaches when it comes to implementation. I tried to summarize all what I've ...
user avatar
  • 111
1 vote
0 answers
131 views

Clear Applcation Cache with Event Domain DDD

I want to clear my application cache after updating an element of my domain. In that case i raise an event NodeEndPointReferenceChangedEvent from my Domain Layer. The cache in managed in Services ...
user avatar
1 vote
2 answers
378 views

Entity Framework and Domain Driven Design Testability

I'm using a DDD approach for the Domain classes. Although, I have a problem on my design, that I'm handling it now but didn't have a good idea to over tackle it. My Architecture is the follow one: - ...
user avatar
1 vote
0 answers
348 views

Where to place the Value Object code that is shared by more than one Aggregate Root?

I have 2 Aggregate Root: One is the Lessor user, and the other is the Lessee user. class Lessor extends AggregateRoot {} class Lessee extends AggregateRoot {} Each of these Aggregate Roots has a ...
user avatar
1 vote
0 answers
134 views

How to manage data in an Aggregate

This is an overly simplistic example of a domain model for a time keeping domain. I only started on it today as a way to practice the techniques I'm learning while reading Implementing Domain-Driven-...
user avatar
  • 137
1 vote
0 answers
133 views

Commiting transaction in the repository instead of the application service

After quite some time thinking about it, and testing both methods, I'm really struggling with choosing the right manner to commit my transactions. To shape the context, we are in the context of ...
user avatar
  • 427
1 vote
0 answers
778 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://...
user avatar
  • 6,855
1 vote
0 answers
382 views

Aggregate root circular dependency when data needed for calculation

My original design has a domain service that did a lot of work which resulted in an Anemic Domain Model (concepts like BalanceCalculators, AccountServices, etc.). I refactored my design which resulted ...
user avatar
  • 1,159
1 vote
0 answers
350 views

Splitting a Bounded Context - administration and execution

TLDR: not quite sure whether I got my Bounded Context right. Situation I have a domain model in one Bounded Context: Entire model is in the same bounded context. Bounded context has two ...
user avatar
  • 747
1 vote
0 answers
91 views

DDD: How to resolve aggregate members needing dependecies?

I have the following aggregate: Checkout (root) Requirement: CouponRequirement, AnotherRequirement, YetAnotherRequirement Coupon A Checkout has many requirements that need to be fulfilled in order ...
user avatar
1 vote
0 answers
450 views

DDD: Application Services Code Reuse

I'm struggling in how to represent and reuse some "operations" that are commonly done by the Applications Services but aren't part of the Domain. A bit of context: I implement CQRS for the ...
user avatar
1 vote
0 answers
2k 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 ...
user avatar