Questions tagged [domain-driven-design]
Domain-driven design (DDD) is an approach to developing software for complex needs by deeply connecting the implementation to an evolving model of the core business concepts. Note that conceptual DDD questions are better to be asked at softwareengineering.stackexchange.com.
6,848
questions
570
votes
14
answers
247k
views
What is the difference between DAO and Repository patterns?
What is the difference between Data Access Objects (DAO) and Repository patterns? I am developing an application using Enterprise Java Beans (EJB3), Hibernate ORM as infrastructure, and Domain-Driven ...
428
votes
7
answers
189k
views
Where do I find some good examples for DDD? [closed]
I'm learning about Domain Driven Design, however there are some practical issues that are confusing to me that I think seeing some good samples might clear up.
Does anyone know of some good working ...
381
votes
8
answers
143k
views
Domain Driven Design: Domain Service, Application Service [closed]
Can someone explain the difference between domain and application services by providing some examples? And, if a service is a domain service, would I put the actual implementation of this service ...
311
votes
2
answers
82k
views
What is Domain Driven Design (DDD)? [closed]
I keep seeing DDD (Domain Driven Design) being used a lot in articles - I have read the Wikipedia entry about DDD but still can't figure out what it actually is and how I would go about implementing ...
300
votes
9
answers
108k
views
Should services always return DTOs, or can they also return domain models?
I'm (re)designing large-scale application, we use multi-layer architecture based on DDD.
We have MVC with data layer (implementation of repositories), domain layer (definition of domain model and ...
238
votes
13
answers
52k
views
DDD - the rule that Entities can't access Repositories directly
In Domain Driven Design, there seems to be lots of agreement that Entities should not access Repositories directly.
Did this come from Eric Evans Domain Driven Design book, or did it come from ...
217
votes
9
answers
109k
views
What is Domain Driven Design?
Can somebody please explain (in succinct terms) what exactly is domain driven design? I see the term quite a lot but really don't understand what it is or what it looks like. How does it differ from ...
133
votes
9
answers
63k
views
DTO = ViewModel?
I'm using NHibernate to persist my domain objects.
To keep things simple I'm using an ASP.NET MVC project as both my presentation layer, and my service layer.
I want to return my domain objects in ...
132
votes
9
answers
52k
views
Value vs Entity objects (Domain Driven Design)
I have just started reading DDD. I am unable to completely grasp the concept of Entity vs Value objects.. Can someone please explain the problems (maintainability, performance.. etc) a system could ...
117
votes
12
answers
34k
views
Confused about Bounded Contexts and SubDomains
I've read Eric Evan's book and am reading Vaughn Vernon's book now. I'm in the second chapter where he talks about subdomains and bounded context and am thoroughly confused now.
From what I was able ...
99
votes
5
answers
76k
views
What is the difference between domain objects, POCOs and entities?
I was under the impression they are all basically the same. Are model objects also the same?
Right now, in my architecture, I have:
class Person
{
public string PersonId;
public ...
93
votes
15
answers
15k
views
Why should I isolate my domain entities from my presentation layer?
One part of domain-driven design that there doesn't seem to be a lot of detail on, is how and why you should isolate your domain model from your interface. I'm trying to convince my colleagues that ...
89
votes
2
answers
23k
views
Access Control in Domain Driven Design
I read about DDD and Access Control, and I found some contradiction between the following two opinions:
"security concerns should be handled outside the domain"
"access control ...
88
votes
3
answers
13k
views
Having Separate Domain Model and Persistence Model in DDD
I have been reading about domain driven design and how to implement it while using code first approach for generating a database. From what I've read and researched there are two opinions around this ...
87
votes
5
answers
67k
views
DDD - which layer DTO should be implemented
I am learning about DDD so apologies if my question is naive. I think I need to use Local Data Transfer Object in order to display data to the users as a lot of properties are not part of any of ...
87
votes
4
answers
26k
views
How to map View Model back to Domain Model in a POST action?
Every article found in the Internet on using ViewModels and utilizing Automapper gives the guidelines of the "Controller -> View" direction mapping. You take a domain model along with all Select ...
87
votes
5
answers
11k
views
Reducing Repositories to Aggregate Roots
I currently have a repository for just about every table in the database and would like to further align myself with DDD by reducing them to aggregate roots only.
Let’s assume that I have the ...
85
votes
4
answers
35k
views
DDD - Persistence Model and Domain Model
I am trying to learn domain-driven design (DDD), and I think I got the basic idea. But there is something confusing me.
In DDD, are the persistence model and domain model different things? I mean, we ...
84
votes
8
answers
17k
views
CQRS Event Sourcing: Validate UserName uniqueness
Let's take a simple "Account Registration" example, here is the flow:
User visit the website
Click the "Register" button and fill out the form, click the "Save" button
...
81
votes
6
answers
34k
views
EF codefirst : Should I initialize navigation properties?
I had seen some books(e.g programming entity framework code first Julia Lerman) define their domain classes (POCO) with no initialization of the navigation properties like:
public class User
{
...
78
votes
2
answers
20k
views
How are Value Objects stored in the database?
I haven't really seen any examples, but I assume that they are saved inside the containing entity table within the database.
Ie. If I have a Person entity/aggregate root and a corresponding Person ...
75
votes
10
answers
20k
views
Where to put global rules validation in DDD
I'm new to DDD, and I'm trying to apply it in real life. There is no questions about such validation logic, as null check, empty strings check, etc - that goes directly to entity constructor/property. ...
70
votes
2
answers
39k
views
Iterator versus Stream of Java 8
To take advantage of the wide range of query methods included in java.util.stream of Jdk 8 I am attempted to design domain models where getters of relationship with * multiplicity (with zero or more ...
70
votes
5
answers
42k
views
Rest API and DDD
In my project using DDD methodology.
The project has the aggregate(entity) Deal. This aggregate has many of use cases.
For this aggregate I need to create a rest api.
With standard: create and ...
70
votes
5
answers
33k
views
DDD and MVC: Difference between 'Model' and 'Entity'
I'm seriously confused about the concept of the 'Model' in MVC. Most frameworks that exist today put the Model between the Controller and the database, and the Model almost acts like a database ...
69
votes
4
answers
44k
views
Difference between an entity and an aggregate in domain driven design
Please what is the main difference between entities and aggregate roots in domain driven design. For example in entity framework, what is the use of aggregates if I can ensure data integrity entities?
69
votes
7
answers
23k
views
Is DDD a waste of time? [closed]
Googling "What kind of applications is DDD suitable for?" gave me the following answer:
Probably 95% of all software applications fall into the “not so good for using DDD” categories. (see the ...
67
votes
5
answers
21k
views
Validation in a Domain Driven Design
How do you deal with validation on complex aggregates in a domain driven design? Are you consolidating your business rules/validation logic?
I understand argument validation and I understand property ...
67
votes
3
answers
20k
views
What is the difference between Command + CommandHandler and Service?
I have been reading about using Command objects to represent use cases that our domain exposes, and Command Handler objects to process those commands.
For example:
RegisterUserCommand
...
64
votes
5
answers
14k
views
Doctrine Entities and business logic in a Symfony application
Any ideas / feedback are welcome :)
I run into a problem in how to handle business logic around my Doctrine2 entities in a big Symfony2 application. (Sorry for the post length)
After reading many ...
62
votes
6
answers
36k
views
Domain Driven Design and the role of the factory class
I'am unclear as to what the roles and responsibility of the factory class is. I know enough that the factory class should be resposible for the creation of domain objects (aggregate root) along with ...
60
votes
9
answers
25k
views
CQRS Examples and Screencasts [closed]
I'm looking for some in depth end-to-end CQRS examples with a reasonable set of unit tests.
Also, if anyone knows of some CQRS screencasts as well it would be extremely handy.
I'm already aware of ...
60
votes
7
answers
31k
views
Transactions in the Repository Pattern
How do I encapsulate the saving of more than one entity in a transactional manner using the repository pattern? For example, what if I wanted to add an order and update the customer status based on ...
55
votes
4
answers
23k
views
Domain Driven Design vs Model Driven Architecture
I am curious, what are the differences between Domain Driven Design and Model Driven Architecture? I have the impression they have certain similarities.
Could you enlighten me?
Thanks
54
votes
16
answers
2k
views
Is non-programmatic software development feasible? [closed]
I'm currently faced with a very unusual design problem, and hope that a developer wiser than myself might be able to offer some insight.
Background
Without being too specific, I've been hired by a ...
54
votes
6
answers
51k
views
Repository pattern and mapping between domain models and Entity Framework
My repositories deal with and provide persistence for a rich domain model. I do not want to expose the anemic, Entity Framework data entity to my business layers, so I need some way of mapping ...
54
votes
3
answers
14k
views
How does a service layer fit into my repository implementation?
I have created a POCO model class and a repository class which handles persistence. Since the POCO cannot access the repository, there are lots of business logic tasks in the repository which doesn't ...
52
votes
5
answers
9k
views
What is a practical way to model lookup tables in Domain Driven Design (DDD)?
I'm just learning DDD (Eric Evans book is open in front of me) and I've come across a problem that I can't find an answer for. What do you do in DDD when you're just trying to get a simple list of ...
50
votes
7
answers
8k
views
What is domain driven design? [closed]
So I got this question from one of the developers in my team: What is domain driven design? I could of course point to the book from Evans but is that actually an answer?
How would you explain DDD ...
50
votes
12
answers
11k
views
Domain Validation in a CQRS architecture
Danger ... Danger Dr. Smith... Philosophical post ahead
The purpose of this post is to determine if placing the validation logic outside of my domain entities (aggregate root actually) is actually ...
50
votes
5
answers
3k
views
How to avoid anemic domain models, or when to move methods from the entities into services
I have a common scenario that I am looking for some guidance from people more experienced with DDD and Domain Modeling in general.
Say I start out building a blog engine, and the first requirement is ...
49
votes
7
answers
14k
views
What specific issue does the repository pattern solve?
(Note: My question has very similar concerns as the person who asked this question three months ago, but it was never answered.)
I recently started working with MVC3 + Entity Framework and I keep ...
49
votes
4
answers
16k
views
Should Domain Entities be exposed as Interfaces or as Plain Objects?
Should Domain Entities be exposed as Interfaces or as Plain Objects ?
The User Interface :
public interface IUser
{
string FirstName { get; set; }
string LastName { get; set; }
string ...
48
votes
3
answers
16k
views
CQRS Commands and Queries - Do they belong in the domain?
In CQRS, do they Commands and Queries belong in the Domain?
Do the Events also belong in the Domain?
If that is the case are the Command/Query Handlers just implementations in the infrastructure?
...
47
votes
6
answers
10k
views
Inheritance vs enum properties in the domain model
I had a discussion at work regarding "Inheritance in domain model is complicating developers life". I'm an OO programmer so I started to look for arguments that having inheritance in domain model will ...
47
votes
2
answers
31k
views
How do Repositories fit with CQRS?
According to Fowler (here), a repository "mediates between the domain and data mapping layers, acting like an in-memory domain object collection." So, for example, in my Courier Service application, ...
46
votes
5
answers
11k
views
Is it problematic that Spring Data REST exposes entities via REST resources without using DTOs?
In my limited experience, I've been told repeatedly that you should not pass around entities to the front end or via rest, but instead to use a DTO.
Doesn't Spring Data Rest do exactly this? I've ...
46
votes
6
answers
16k
views
Why does domain driven design seem only popular with static languages like C# & Java? [closed]
Domain driven design has become my architecture of choice. I've been able to find a abundance of books & tutorials for applying DDD principles within the ASP.net framework. It mostly seems ...
45
votes
6
answers
17k
views
Value objects in DDD - Why immutable?
I don't get why value objects in DDD should be immutable, nor do I see how this is easily done. (I'm focusing on C# and Entity Framework, if that matters.)
For example, let's consider the classic ...
45
votes
5
answers
13k
views
CQRS and Event Sourcing Difference
What is the difference between CQRS (Command Query Responsibility Segregation) and Event Sourcing?
I believe Event Sourcing is a type of CQRS. What distinguishes each, and what makes Event Sourcing ...