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
9 votes
2 answers
4k 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 ...
w0051977's user avatar
  • 7,021
51 votes
4 answers
24k 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 { ...
adisembiring's user avatar
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 ...
w0051977's user avatar
  • 7,021
225 votes
11 answers
30k 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 ...
user1318496's user avatar
  • 1,767
48 votes
2 answers
19k 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 ...
anjunatl's user avatar
  • 598
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 ...
Michael's user avatar
  • 6,437
8 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 ...
w0051977's user avatar
  • 7,021
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 ...
Paul T Davies's user avatar
13 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,...
Lauri Harpf's user avatar
12 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 ...
Dario Granich's user avatar
8 votes
4 answers
13k 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 ...
BanksySan's user avatar
  • 714
5 votes
1 answer
3k views

DDD with web api, validation in domain or application layer?

I saw a lot of discussion, but I don't know how to do it in a real world. I understand that validation duplication in the client and server is needed. But how to elegantly validate in server and ...
Libron's user avatar
  • 61
85 votes
7 answers
103k 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 ...
Louis Rhys's user avatar
  • 6,042
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 ...
Great Turtle's user avatar
36 votes
3 answers
26k 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 ...
LittlePilgrim's user avatar
30 votes
2 answers
9k 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 ...
EagleBeak's user avatar
  • 519
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 ...
P.Brian.Mackey's user avatar
19 votes
2 answers
10k 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 ...
Andy's user avatar
  • 10.2k
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 ...
lko's user avatar
  • 377
15 votes
5 answers
16k 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 ...
Darthg8r's user avatar
  • 257
15 votes
3 answers
15k 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 ...
Pavel Voronin's user avatar
15 votes
2 answers
12k 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 ...
keelerjr12's user avatar
  • 1,199
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 ...
SonOfPirate's user avatar
  • 2,885
12 votes
1 answer
982 views

Do ORM POCOs replace domain entities?

This is somewhat similar to this question but more broad. In general, with ORMs like EF 4.1 supporting POCOs, does it now make sense to have your domain entities be the objects that are persisted to ...
Adam Rackis's user avatar
12 votes
3 answers
5k 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 ...
Sjoerd222888's user avatar
11 votes
4 answers
9k 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 ...
JD01's user avatar
  • 1,289
10 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 ...
w0051977's user avatar
  • 7,021
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 ...
Joeri Hendrickx's user avatar
6 votes
2 answers
3k 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 ...
w0051977's user avatar
  • 7,021
6 votes
3 answers
6k 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 ...
Peppermintology's user avatar
6 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,...
Omu's user avatar
  • 305
4 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, ...
Noren's user avatar
  • 173
3 votes
1 answer
307 views

Where does complex, heavyweight validation logic go?

I've been struggling to figure out a clean way to validate things when objects have complex relationships and the validation requires expensive operations (e.g., making DB queries or other RPCs). ...
Richard Levasseur's user avatar
3 votes
1 answer
1k views

Doubts about architectural pattern for customizable standard enterprise application [duplicate]

My company needs to build an application to be rolled out for a lot of clients. This software will have many modules and functionalities, but some of these will need specific adjustments for some ...
Dherik's user avatar
  • 2,426
2 votes
1 answer
2k 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=...
Matt Smith's user avatar
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 ...
w0051977's user avatar
  • 7,021
1 vote
1 answer
424 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 ...
w0051977's user avatar
  • 7,021
1 vote
3 answers
3k 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 ...
w0051977's user avatar
  • 7,021
101 votes
5 answers
15k 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 ...
SonOfPirate's user avatar
  • 2,885
96 votes
6 answers
136k 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 ...
tintin's user avatar
  • 1,233
82 votes
4 answers
6k 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 ...
Sandor Drieënhuizen's user avatar
60 votes
4 answers
45k 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 ...
mfrachet's user avatar
  • 1,481
56 votes
6 answers
25k 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. ...
Erik Funkenbusch's user avatar
50 votes
11 answers
29k 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 ...
richard's user avatar
  • 3,325
46 votes
4 answers
28k 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 ...
Extrakun's user avatar
  • 939
43 votes
5 answers
56k 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 ...
user2484998's user avatar
37 votes
5 answers
25k 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 ...
Alexey's user avatar
  • 1,209
37 votes
7 answers
10k 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 ...
Kazark's user avatar
  • 1,810
35 votes
2 answers
22k 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 ...
Lesair Valmont's user avatar
31 votes
2 answers
9k 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 ...
Shaddix's user avatar
  • 491