We’re rewarding the question askers & reputations are being recalculated! Read more.

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
0
votes
1answer
382 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> ...
3
votes
3answers
350 views

How can database-specific functionality, such as increment/decrement features, be used in DDD?

I have an entity that has a dollar balance property. Whenever an event occurs that causes the balance to change, such as a debit, within the same transaction the balance should be decremented by the ...
1
vote
0answers
238 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 ...
6
votes
2answers
1k views

Where should I put Validation Logic when using CQRS?

I asked this question a while ago: What is the "best" way to apprach validation from the perspective of a DDD purist? At the time I decided to put the validation logic inside the domain ...
5
votes
3answers
338 views

At which moment should event storming be used?

I've recently seem event storming as a quite reasonable way to get understanding form a domain, in order to build a domain model. We understand the events in the domain, which for the domain experts ...
2
votes
2answers
333 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
votes
1answer
286 views

Should the aggregate root have a property that it cannot validate [duplicate]

I ran into the situation where I have to decide whether a property belongs to my aggregate or not. My domain logic is the following. A User has a group in his organization ex: IT, SALES, MARKETING. ...
1
vote
2answers
372 views

Best practices regarding value objects

I had a few questions around value objects in DDD. I had a class ReportDefinition (basically a schema for a specific report that users can create) with the following properties (in Java): UUID id; ...
1
vote
2answers
377 views

DDD: Is there a place for “find or create” in the business logic

Some user actions quite naturally lead to find-or-create situations. For example, user logs into a system by alternative method and find-or-create is called give email. Or, another example, User is ...
-2
votes
1answer
239 views

Role-based declarative security for C#

According to Domain Driven Design and Development In Practice: Spring Security (a sub-project in Spring Portfolio) provides a fine-grained access control in both presentation (URL based) and ...
2
votes
1answer
713 views

DDD and ValueObjects in repository

I have a Product entity with a Category value object (contrived example). There's an API endpoint /products?category=Keyboards,Mice The classes at play here are the: ListProductsController (...
3
votes
3answers
742 views

Is DDD only good for batch processing?

Just read my first book on DDD ("Domain Modeling Made Functional: Tackle Software Complexity with Domain-Driven Design and F#" by Scott Wlaschin in case it makes any difference), and came away with ...
4
votes
2answers
2k views

Why not use an ORM with DDD?

I've just finished reading Scott Wlaschin's excellent book "Domain Modeling Made Functional: Tackle Software Complexity with Domain-Driven Design and F#" in which he uses the F# SQL type provider for ...
0
votes
1answer
413 views

Data Mapper Pattern and DDD - Does ist already reflect domain entities and repositories?

I'm getting used to DDD so don't assume I'm a DDD pro yet. I'm trying to implement a hexagonal architecture using the CakePHP framework in a completely custom made application that just utilizes the ...
6
votes
4answers
2k views

Rich domain model vs strategy pattern in DDD

I've recently watched a few Pluralshigh courses on DDD by Vladimir Khorikov. He was encouraging to create a rich instead of anemic domain models. It all looked very nice in a small test-project, ...
2
votes
3answers
171 views

Proper layer to handle duplicate keys

In a Web Application that has 4 layers: UI layer Business layer Data Access layer Data storage layer which is the database One of the requirements is to handle a list of objects with unique key. ...
2
votes
1answer
343 views

Can one app have several “subdomains” in DDD?

General Context I started reading about layer based architectures like DDD, Onion, Clean Architecture etc. I am considering switching, but am currently unclear about how strict the "first level ...
4
votes
1answer
347 views

DDD: How to work with entity variations?

Let's say I have an Entity that represents an employee: Employee First name Last name Birthdate Hair color Eye color Gender .... (and so on) Now, imagine I have a website ...
-1
votes
1answer
415 views

How to split an onion-style DDD project without using microservices?

Background: I'm building a prototype scientific app with the "Exploration" and "Optimisation" parts. (Other parts might be needed later.) Each part uses functional reactive programming (FRP) and has ...
1
vote
2answers
148 views

How to implement Domain Model with Repository without leaking responsibility?

Imagine, we have test modules with large number of questions and we can create tests which will contain exactly 30 questions. public class Module { public long Id { get; set; } public List&...
2
votes
1answer
192 views

DDD - What could be best fit for AggregateRoot and Entity for Transaction Domain

I'll preface this question by saying I am relatively new to DDD so I may be making some fundamental mistakes here! I am working on a project which involves the concepts of Transactions (in the ...
3
votes
3answers
373 views

Handling domain errors in the API

I'm working on building an API interface on-top of a domain-driven architecture. The domain layer has a bunch of specific exception classes (i.e. NameIsRequiredException, CannotPublishDraftException, ...
1
vote
1answer
347 views

Modeling on Domain Driven Design and C4Model

I am wondering how DDD and C4Model can play together. Level 1 of Simon Brown's c4 Model is System Context diagram. So I think after you find and define your Bounded Contexts, you may start creating ...
2
votes
3answers
4k 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 ...
1
vote
2answers
493 views

In domain-driven design, are entities allowed to handle complex operations such as I/O?

Overview I'm trying to learn about domain-driven design, and I'm about 80% of the way through Eric Evan's book on the subject (and about the same on the Pluralsight course). I've been attempting to ...
4
votes
3answers
902 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, ...
5
votes
1answer
1k 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
0answers
57 views

How to implement M-N relationship to reflect the domain correctly

If I have three entities like this: WorkingGroup WorkingTime Shift The WorkingGroup has one or more workingTime public class WorkingGroup { public WorkingGroup() { ...
0
votes
1answer
220 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 ...
2
votes
1answer
127 views

When should desktop app save to database using UoW?

So one thing I didn't really think about when designing this personal finance application was WHEN (not HOW) to persist the data. I'm using DDD, a 4-tier architecture, and EF. It struck me when I ...
1
vote
1answer
237 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 ...
2
votes
1answer
499 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 ...
3
votes
2answers
2k views

Use a HashSet or List for a collection of Entities?

I have a class, which looks like this: public class Customer { private readonly IList<Order> _orders = new List<Order>(); public FirstName FirstName { get; set; } public ...
3
votes
3answers
440 views

Is an Enum changing the behaviour of an Entity bad?

I am very new to Domain-Driven Design. I have come across a part of a domain which I'm not sure if I have modeled in the best way possible. There is a Membership entity which has a membership type. ...
3
votes
2answers
446 views

DDD handling of tables, repositories, and/or services

Struggling to handle aggregates and aggregate roots when it comes to persisting. For example, I currently have a repository for each aggregate/table, but this is causing some issues in my service ...
211
votes
10answers
26k views

Why do we need so many classes in design patterns?

I am junior developer among seniors and am struggling a lot with understanding their thinking, reasoning. I am reading Domain-Driven Design (DDD) and can't understand why we need to create so many ...
-2
votes
2answers
207 views

Can a Value object exist on its own?

I have read this: https://stackoverflow.com/questions/25450380/can-value-objects-exist-without-entities, which says yes and this: http://enterprisecraftsmanship.com/2016/01/11/entity-vs-value-object-...
1
vote
1answer
253 views

Deciding between a Domain Service and Entity method

I am trying to decide whether to use a Domain Service or an Entity method for a function. Please see the code below: public class Customer { private readonly Guid _id; private readonly ...
1
vote
1answer
100 views

How to verify that every object responsible for Itself

I wonder if I have multiple objects and how to list their responsibilities where every Object Must be Responsible for Itself for example: If I have three objects: Employee,Schedule,Shift. and ...
3
votes
4answers
2k views

Inventory, Pricing and Product Catalog communication

Imagine that I am creating and Ecommerce application. For sake of simplicity, I will describe only 3 bounded contexts. Product Catalog: it's responsible for maintain product descriptions, ...
3
votes
3answers
129 views

Model Customer preferences with different Products for Sellers

I have a model where Sellers can sell Products to Customers. Sellers need to be able to set Preferences for Customers on a specific Product. I can see how that may be confusing so let me give an ...
0
votes
1answer
359 views

Can a Domain Service Also Be a Factory?

I'm creating a domain service for each of my aggregate roots in order to facilitate some logic that won't be able to fit inside the entity themselves. I would rather not implement a factory and ...
4
votes
1answer
466 views

Should Domain Services Raise Events?

I have a business requirement that any account viewed needs to be logged. I'm trying to figure out where this requirement should be in my code. This is a query type event and doesn't require going ...
4
votes
2answers
411 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 ...
-1
votes
1answer
238 views

Using BDD and DDD approaches, which seem to complement and contradict each other

I am trying to apply BDD and DDD together to a new project The problem I am having at the moment can be summed up by the following quote (taken from here: https://www.infoq.com/news/2015/02/bdd-ddd): ...
3
votes
3answers
160 views

Should I use a physical units library for modelling domain properties if I don't need to perform computations on them?

I'm working on the data model of a service describing houses and flats. This involves storing quantitative physical properties of certain features of the premises, for example: Speed of the Internet ...
2
votes
1answer
503 views

How are CQRS write models initially populated?

I have a system that interacts with a REST API as the data source. This system is based on DDD and all of my current models are CRUD models. There is one model that the REST API is only able to query ...
1
vote
1answer
985 views

Clean architecture with C#: A better design to perform validation in Value Objects

I'm creating an application which's architecture is based on Uncle Bob's Clean Architecture concepts and DDD. Note that it is BASED on DDD, so I gave myself the freedom to differ from strict DDD. To ...
0
votes
0answers
910 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 ...
13
votes
2answers
6k views

Implementing DDD: users and permissions

I am working on a small application trying to grasp the principles of domain-driven design. If successful, this might be a pilot for a larger project. I'm trying to follow the book "Implementing ...