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.

37
votes
4answers
15k 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 { ...
7
votes
2answers
819 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 ...
32
votes
2answers
8k 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 ...
39
votes
3answers
18k 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 ...
16
votes
5answers
8k 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 ...
37
votes
7answers
52k 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 ...
24
votes
3answers
11k 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 ...
16
votes
2answers
5k 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 ...
44
votes
7answers
6k 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 ...
22
votes
2answers
5k 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 ...
4
votes
3answers
2k views

What is the “best” way to apprach validation from the perspective of a DDD purist?

I recently asked this question: Validation inside Constructor 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 ...
10
votes
2answers
3k 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,...
6
votes
4answers
2k 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 ...
3
votes
3answers
4k 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,...
13
votes
3answers
4k 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 ...
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 ...
7
votes
3answers
6k 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 ...
7
votes
4answers
989 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 ...
6
votes
2answers
810 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 ...
3
votes
1answer
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, ...
3
votes
2answers
774 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 ...
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 ...
1
vote
3answers
1k 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 ...
1
vote
2answers
550 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 ...
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 ...
89
votes
5answers
12k 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 ...
43
votes
11answers
21k 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 ...
38
votes
6answers
15k 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. ...
61
votes
4answers
4k 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 ...
33
votes
7answers
8k 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 ...
22
votes
6answers
21k 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 ...
18
votes
4answers
8k 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 ...
17
votes
2answers
5k 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 ...
14
votes
2answers
15k 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, ...
25
votes
2answers
14k 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 ...
19
votes
6answers
5k 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 ...
12
votes
4answers
7k 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 ...
14
votes
3answers
3k views

When using DDD and CRQS, should be exactly one event per command?

I am looking for a way to design a ddd application with convention over configuration. Say an aggregate "Client" has a command defined "FillProfile". It will logically raise an event "ProfileFilled". ...
21
votes
2answers
5k 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 ...
12
votes
2answers
1k views

What question is answered by DDD? [duplicate]

What is the problem that is solved by Domain Driven Design? I understand what Object Oriented Programming brought and see the issues it addressed and how, and in what aspect/scenaria, it made the ...
9
votes
2answers
3k views

Is there an elegant way to check unique contraints 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 ...
9
votes
3answers
8k views

Presentation VS Application layer in DDD

I have trouble drawing a clear line between Presentation and Application layer in Domain Driven Design. Where should Controllers, Views, Layouts, Javascript and CSS files go? Is it in the ...
8
votes
1answer
2k views

Unique Value Object vs Entity

Trying to convert some entities into value objects I am stuck in a case where what seems a value object must be unique within an aggregate. Suppose we have a Movie entity which makes the root of an ...
16
votes
1answer
2k views

Is Domain Driven Design useful / productive for not so complex domains?

When assessing a potential project at work, I suggested that it might be advantageous to use a domain driven design approach to its object model. The project does not have an excessively complex ...
12
votes
2answers
3k views

Are Persistence-Ignorant objects able to implement lazy loading?

Persistence Ignorance is an application of single responsibility principle, which in practice means that Domain Objects (DO) shouldn't contain code related to persistence, instead they should only ...
6
votes
3answers
7k 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 ...
11
votes
5answers
5k views

If Repository Pattern is overkill for modern ORMs (EF, nHibernate), what is a better abstraction?

I've recently read a lot of arguments against using the repository pattern with powerful ORM's like Entity Framework as it incorporates repository-like functionality, along with Unit of Work ...
10
votes
2answers
1k views

How to design the aggregate boundaries?

I would like to write an application something like ecommerce. And you know that in similar applications products could have different properties and features. To simulate such an opportunity I've ...
8
votes
1answer
762 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 ...
7
votes
1answer
1k views

Updating nested objects in DDD Aggregate by example: delegation or direct access from the root?

The example domain problem There is a student attendance tracking system that keeps records of student attendances of ExerciseGroups. Course is a top-level component, AR, describes a generic info ...