Stack Exchange Network

Stack Exchange network consists of 175 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.

1
vote
3answers
2k 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
283 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
538 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, ...
2
votes
1answer
757 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
133 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
113 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
149 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
346 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
2answers
1k 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
326 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
291 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 ...
206
votes
10answers
25k 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
194 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
179 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
98 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 ...
1
vote
4answers
870 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. 1. Product Catalog: it's responsible for maintain product descriptions, ...
4
votes
3answers
114 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
276 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 ...
3
votes
1answer
270 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 ...
3
votes
2answers
252 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
199 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
155 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
425 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
550 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
615 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 ...
9
votes
2answers
3k 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 ...
1
vote
1answer
195 views

Have I understood the term Honeycomb correctly?

Following on from my previous question and the comments under the accepted answer: One Acceptance Test project per layer or one Acceptance Test project per Bounded Context I have done a lot of ...
0
votes
2answers
93 views

How to link domain specifications with the code implementation without forcing domain expert to adopt any particular practice

Our current business process is that the domain experts will write down the business logic in a Word document, and developers will try to reflect those logic as closely as possible with the ...
-1
votes
1answer
259 views

One Acceptance Test project per layer or one Acceptance Test project per Bounded Context

This link (http://www.taimila.com/blog/ddd-and-testing-strategy/) says: "Feature tests should depend only on the application layer" i.e. presentation layer. I am trying to understand how BDD fits in ...
0
votes
2answers
326 views

How to design classes in php in respository pattern?

I use laravel with repository pattern. My project strucuture is: I have an Entity class(POPO) which implements an Interface and has a repository class related to it. For example for a User Entity, ...
-2
votes
1answer
123 views

Modeling sprint and ticket in DDD

I'm trying to learn DDD/CQRS in a hobby project. And have no prior experience. In this project I use MongoDb as a read db and EventStore as a write db. I'm building a simple 'Sprint board' ...
2
votes
2answers
974 views

Is the builder pattern applicable in domain driven design?

I asked a question on StackOverflow regarding how to 'best' use the Builder pattern for constructing a Value Object which could be constructed with or without optional parameters. One answer stated ...
0
votes
2answers
123 views

Testing a class that only has one field only that is an ID number

I am trying to incorporate BDD into the teams working practices to make interactions with Business Analysts more effective. I recently asked this question: Should I pass an ID number from the feature ...
9
votes
1answer
2k views

Exceptions in DDD

I'm learning DDD and I'm thinking about throwing exceptions in certain situations. I understand that an object can not enter to a bad state so here the exceptions are fine, but in many examples ...
0
votes
3answers
309 views

Should I pass an ID number from the feature file?

Say I have a domain object like this: public class Customer { private Guid _id; private string _name; private Address _address; public Customer (Guid id, string name, Address address)...
0
votes
3answers
921 views

DDD: Event handlers and aggregates in functional programming

When implementing a DDD driven system (based on event sourcing) using a functional programming language (Clojure), should one separate event handler functions from aggregate functions? In my naive ...
1
vote
1answer
86 views

Valid values of properties on Aggregate Roots controlled by other Domains

We are currently beginning an upgrade to our system and have decided to follow DDD methodology. The system is highly customizable by the users to allow them to tailor the software to their specific ...
2
votes
2answers
536 views

How does “Composition Root” DI apply to Domain Driven Design?

I'm confused about applying the "Composition Root" (CR) to create aggregates in DDD. Seemann (2012) defines CR as a "(preferably) unique location ... where modules are composed". He argues for ...
3
votes
2answers
253 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....
2
votes
1answer
37 views

Advice on AggregateRoot boundaries

I am confused on how to apply DDD principles for the design of domain entity clusters with Aggregate Root. According to my understanding, Aggregate Root enforces business validations and all entities ...
3
votes
3answers
3k views

Data Entities, Domain entities and the repositories

I'm trying to get my head around DDD but I'm stuck. This is how I setup my project: Data Access Layer -Entity models that map to the db -Db connection stuff -Repositories implementations Domain ...
1
vote
1answer
500 views

Naming a Domain Model project

This question follows on from my other question here: How does an isolated class (or group of isolated classes) fit into a Domain Model? I have looked at a few domain models online: https://github....
3
votes
3answers
180 views

How does an isolated class (or group of isolated classes) fit into a Domain Model?

I am trying to refactor a large and complex application to use DDD principles as and when I get time. I have a class, which is completely isolated from the domain (it is only used by an application ...
2
votes
3answers
785 views

Who owns the Orders in a consumer-provider marketplace like platform?

We are developing an application where providers can offer their products and consumers can buy them (sort of marketplace). We try to apply DDD concepts into our model design and the implementation ...
2
votes
6answers
240 views

Should I use a collection property if I only require an object at the moment?

Please see the class below: public class Customer { private readonly IList<Order> _orders = new List<Order>(); public string FirstName { get; set; } public ...
3
votes
1answer
2k views

DDD - Are 'use cases' and 'application services' different names for the same thing?

I'm struggling a little bit with Domain Driven Design because there are so many names and concepts to grasp. Today it striked me to know what is exactly the difference between an 'application service'...
6
votes
3answers
574 views

How do I avoid implementing my Event Sourced projections twice?

I'm currently teaching myself event sourcing and have got the concept enough to start developing a dummy app in C# and EventStore. My app is an easy-to-understand bank account system. If we model a ...
0
votes
2answers
477 views

Including aggregate data in web service response in DDD

I've been struggling with this issue for a while. Let's say you have a business application that has a rich domain and in one of the front-end views you show a list of open Orders. In this view you ...
3
votes
3answers
295 views

With event sourcing, how to get the response of a call that is a side-effect?

Let's say my user requests my ES/CQRS system to open a support ticket: The controller sends an ask-support command, this command checks if the user has enough credit to do that, then emits an asked-...