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
8 votes
2 answers
3k views

Zero argument constructors and Always Valid entities

I have done a lot of reading recently about Always Valid domain entities. I have come to believe that in order to ensure the entities are always valid I need to: 1) Remove primitive obsession and ...
user avatar
  • 6,855
47 votes
4 answers
23k views

Where we should put validation for domain model

I still looking best practice for domain model validation. Is that good to put the validation in constructor of domain model ? my domain model validation example as follows: public class Order { ...
user avatar
43 votes
3 answers
20k views

What, in reference to DDD, is a bounded context?

When working through the book "Implementing Domain Driven Design" by Vaughn Vernon, I have been unable to gain a good grasp on what a bounded context actually is. The book defines a bounded context ...
user avatar
  • 6,326
47 votes
2 answers
17k views

How do you handle shared concepts in a microservice architecture?

I am researching architectural patterns for an application I'm developing and a microservice approach seems like it would be a good choice but I am not sure how to handle interactions between the ...
user avatar
  • 588
7 votes
3 answers
7k views

What is the "best" way to approach validation from the perspective of a DDD purist?

I recently asked this question. I am trying to decide where to put the validation in a DDD app. I believe it should be done at every layer. I am now concentrating on the Domain model. I was ...
user avatar
  • 6,855
29 votes
9 answers
10k views

When is primitive obsession not a code smell?

I have read plenty of articles recently that describe primitive obsession as a code smell. There are two benefits of avoiding primitive obsession: It makes the domain model more explicit. For ...
user avatar
  • 6,855
221 votes
11 answers
29k 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 ...
user avatar
  • 1,707
17 votes
5 answers
10k views

Is it bad practice for services to share a database in SOA?

I have recently been reading Hohpe and Woolf's Enterprise Integration Patterns, some of Thomas Erl's books on SOA and watching various videos and podcasts by Udi Dahan et al. on CQRS and Event Driven ...
user avatar
11 votes
2 answers
4k views

Where to validate domain model rules that depend on database content?

I'm working on a system that allows Administrators to define Forms that contain Fields. The defined Forms are then used to enter data to the system. Sometimes the Forms are filled by a human via a GUI,...
user avatar
7 votes
3 answers
11k views

ID properties on Domain objects in DDD

In my domain I have an Account object. e.g. class Account { public string Number; public string SortCode; } Within the context of DDD, should this account object have an ID property? The ID ...
user avatar
  • 714
76 votes
7 answers
89k views

Application layer vs domain layer?

I am reading Domain-Driven Design by Evans and I am at the part discussing the layered architecture. I just realized that application and domain layers are different and should be separate. In the ...
user avatar
  • 5,932
15 votes
5 answers
15k views

Find the DDD Aggregate Root

Let's play everyone's favorite game, find the Aggregrate Root. Let's use the canonical Customer/Order/OrderLines/Product problem domain. Traditionally, Customer, order, and product are the AR's with ...
user avatar
  • 257
27 votes
3 answers
12k views

What is Domain Driven Development in practical terms? [closed]

I heard about Domain Driven Development from a developer in the area. He talked it up like it was just about the silver bullet to changing requirements. I read the wiki. Still not too clear. What ...
user avatar
18 votes
2 answers
8k views

DDD Bounded Contexts & Domains?

I've been working in a relatively complex application with 10's of database tables (Aggregates, Entities/Value Objects) and applying DDD. At this point it appears to be basically DDD-Lite meaning that ...
user avatar
  • 357
15 votes
2 answers
9k views

Is there an elegant way to check unique constraints on domain object attributes without moving business logic into service layer?

I have been adapting domain-driven design for about 8 years now and even after all these years, there is still one thing, that has been bugging me. That is checking for a unique record in data storage ...
user avatar
  • 9,895
44 votes
8 answers
7k views

Can a system be 100% Data Driven?

My new boss has been working on this project for many years. I've only been here a few weeks, but I am not sure it's possible. He would like to design a system that is "100% data driven". So if we ...
user avatar
28 votes
2 answers
8k views

Best practices for serialization of DDD aggregates

According to DDD domain logic should not be polluted with technical concerns like serialization, object-relational mapping, etc. So how do you serialize or map the aggregates' state without publicly ...
user avatar
  • 489
30 votes
3 answers
20k 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 ...
user avatar
15 votes
3 answers
13k views

How to work with large aggregate roots?

I'm learning DDD and yet I have more questions than answers. Let's consider a model of a directory containing enormous number of files. Here is how I see it: Directory is an Aggregate root. This ...
user avatar
14 votes
2 answers
9k 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 ...
user avatar
  • 1,159
8 votes
4 answers
5k views

In DDD, how do I persist an aggregate containing polymorphism

I've been developing applications according to the principles of DDD for a while now, and, as many, I often run into issues when it comes to persisting an aggregate. One of the main advantages of DDD ...
user avatar
4 votes
3 answers
6k views

DDD + POCO does this makes sense?

DDD promotes rich domain models with behavior in it, POCO naked objects without any objects in it. Is it possible to have them both combined? I have a Multi Layer Solution Core - has POCO Entieties,...
user avatar
  • 285
10 votes
1 answer
980 views

How to use BDD to unit test a compiler?

My team is writing a compiler for a domain-specific language (DSL) which will be integrated into an IDE. Right now, we are focused on the analysis phase of the compiler. We are not using any existing ...
user avatar
  • 217
13 votes
3 answers
5k views

Validation and authorization in layered architecture

I know you are thinking (or maybe yelling), "not another question asking where validation belongs in a layered architecture?!?" Well, yes, but hopefully this will be a little bit of a different take ...
user avatar
  • 2,845
11 votes
4 answers
2k views

How to clearly define boundaries of a bounded context

After a month or so of reading and researching DDD, I decided to start my own project and created DDD with these bounded contexts> Clients Products Orders Billing Each bounded context has rest API ...
user avatar
8 votes
2 answers
3k 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 ...
user avatar
  • 6,855
5 votes
2 answers
2k views

Should a Rich Domain Model have repositories injected in some situations?

Please see the code below, which I took from Jimmy Bogards wicked domain models: public Offer AssignOffer(OfferType offerType, IOfferValueCalculator valueCalculator) { DateTime ...
user avatar
  • 6,855
3 votes
1 answer
2k views

Recovering an anemic domain model into a multitier architecture

I have spent the past several days learning about domain driven design and attempting to apply it to a current project. I decomposed the problem domain into the canonical logical components: domain, ...
user avatar
  • 163
1 vote
1 answer
1k views

Which Software Layer should hold Pagination Information?

Which layer should hold pagination information? (Page Size, Page Number), Eg say 100 products, 5 product per 20 pages. User can type in API url layer. api/Product?Page=1&Limit=2&ColumnSort=...
user avatar
10 votes
4 answers
8k views

What is a value object in domain-driven design?

I have an entity and I've realised that there is a group of properties that work together. So, I moved them to a value object (together with their behavior) and now I have a reference from my entity ...
user avatar
  • 1,279
11 votes
3 answers
4k views

Confusion about the meaning of the word aggregate in domain driven design

In a discussion about domain driven design I have learned the different people seem to think of different things when using the word aggregate. The main difficulty is that some people use the word ...
user avatar
1 vote
1 answer
382 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 ...
user avatar
  • 6,855
1 vote
3 answers
2k views

Domain Driven Design in an Onion Architecture

I recently asked this question: Should the domain layer be dependent on NHibernate? I have read a lot of questions today, where answerers state that the Domain Layer should only contain Business ...
user avatar
  • 6,855
1 vote
2 answers
2k views

Should I mock a Domain Service?

I am trying to decide whether to introduce mocks in my isolated Domain Model tests. I have a class method similar to this: public Offer AssignOffer(OfferType offerType, IOfferValueCalculator ...
user avatar
  • 6,855
98 votes
5 answers
14k views

With all of these services, how can I not be anemic?

Where do we draw the line between delegation and encapsulation of business logic? It seems to me that the more we delegate, the more anemic we become. However, delegation also promotes reuse and the ...
user avatar
  • 2,845
55 votes
6 answers
24k views

Are DDD Aggregates really a good idea in a Web Application?

I'm diving in to Domain Driven Design and some of the concepts i'm coming across make a lot of sense on the surface, but when I think about them more I have to wonder if that's really a good idea. ...
user avatar
50 votes
11 answers
28k 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 ...
user avatar
  • 3,315
87 votes
6 answers
122k views

Difference between a service class and a Helper class [closed]

I would like to know what differentiates a Service class from a utility class or a helper class? A class only with underlying methods calls the dao's is a service? Doesn't the usage of Helper ...
user avatar
  • 1,133
51 votes
4 answers
39k views

DDD repositories in application or domain service

I m studying DDD these days, and I m having some questions concerning how to manage repositories with DDD. Actually, I have met two possibilies : First one The first way of manage services I've ...
user avatar
  • 1,381
80 votes
4 answers
5k views

Programming and Ubiquitous Language (DDD) in a non-English domain

I know there are some questions already here that are closely related to this subject but none of them take Ubiquitous Language as the starting point so I think that justifies this question. For ...
user avatar
39 votes
4 answers
23k views

In DDD, is validation application logic, or domain logic?

Suppose that we are modelling a form using DDD; the form may have certain kind of business rules associated with it - perhaps you will need to specify an income if you are not a student, and you are ...
user avatar
  • 809
40 votes
5 answers
53k 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 ...
user avatar
28 votes
2 answers
13k views

How exactly should a CQRS Command be validated and transformed to a domain object?

I have been adapting poor-man's CQRS1 for quite some time now because I love its flexibility to have granular data in one data store, providing great possibilities for analysis and thus increasing ...
user avatar
  • 9,895
37 votes
7 answers
9k views

Do RESTful APIs tend to encourage anemic domain models?

I'm working on a project in which we are trying to apply both domain-driven design and REST to a service-oriented architecture. We aren't worrying about 100% REST compliance; it would probably be ...
user avatar
  • 1,810
27 votes
2 answers
19k views

DDD: is it correct for a root aggregate to hold a reference to another root aggregate?

When following Domain-driven design (DDD), is it correct for a root aggregate to hold a reference to an internal entity that happens to be the root entity on a separate aggregate? I believe this is ...
user avatar
18 votes
2 answers
18k views

Is this a good Visual Studio solution structure for a domain driven design RESTful web service?

I am building a .NET 4.5 C# Web API RESTful solution and I would like someone to tell me if my project solution is correct and/or wise(-enough?) for a solution designed using Domain Driven Design, ...
user avatar
  • 445
22 votes
4 answers
4k views

How does persistence fit into a purely functional language?

How does the pattern of using command handlers to deal with persistence fit into a purely functional language, where we want to make IO-related code as thin as possible? When implementing Domain-...
27 votes
5 answers
15k views

Which layer do DDD Repositories belong to?

In his DDD book Evans promotes the idea of layered architecture, and in particular that the business logic should be confined to domain layer and separated from UI/persistence/other concerns. He also ...
user avatar
  • 1,099
15 votes
4 answers
8k views

Accessing Repositories from Domain

Say we have a task logging system, when a task is logged, the user specifies a category and the task defaults to a status of 'Outstanding'. Assume in this instance that Category and Status have to be ...
user avatar
29 votes
2 answers
8k views

Domain-Driven-Design - external dependencies in the Entity problem

I'd like to start Domain-Driven-Design, but there are several problems I'd like to solve before starting :) Let's imagine I have a Groups and Users and when user wants to join a group, I'm calling ...
user avatar
  • 471