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.

The premise of domain-driven design is the following:

  • Placing the project's primary focus on the core domain and domain logic
  • Basing complex designs on a model
  • Initiating a creative collaboration between technical and domain experts to iteratively cut ever closer to the conceptual heart of the problem.

Domain-driven design is not a technology or a methodology. DDD provides a structure of practices and terminology for making design decisions that focus and accelerate software projects dealing with complicated domains.

The term was coined by Eric Evans in his book of the same title: Domain-Driven Design: Tackling Complexity in the Heart of Software

Books

Sample Application

6728 questions
19
votes
3 answers

Should Domain Model Classes always depend on primitives?

Halfway through Architecture Patterns with Python, I have two questions about how should the Domain Model Classes be structured and instantiated. Assume on my Domain Model I have the class DepthMap: class DepthMap: def __init__(self, map:…
19
votes
3 answers

Should we use 'package by feature' structure with DDD?

After doing some research, I got confirmation that folder-by-feature structure is superior to folder-by-layer structure in the majority of cases. To get some arguments we can read, among others, the following articles or even this answer. Package…
Kwadz
  • 2,206
  • 2
  • 24
  • 45
19
votes
1 answer

Repository pattern - how to correctly handle JOINs and complex queries?

I have a problem with Repository pattern - how to perform JOIN operations between several repositories. In this project, we use MVC, EF, DDD. I'm aware that this kind of question was here several times, I reference these questions later in this…
19
votes
3 answers

Interaction between unit of work and repository patterns

After reading thorugh plenty of articles I am still unsure about the responsibilities of Unit of Work pattern when interacting with repositories. Repositories are responsible for loading and saving Aggregate root entities, so consider the following…
19
votes
2 answers

Can you suggest DDD best practices

Probably similar questions have been asked many times but I think that every response helps to make the understanding of DDD better and better. I would like to describe how I perceive certain aspects of DDD. I have some basic uncertainties around it…
shaft
  • 2,147
  • 2
  • 22
  • 38
19
votes
3 answers

anemic domain model versus domain model

Being confused again after reading about this anti-pattern and the many concerns about it here on SO. If I have a domain model and capture the data that must be persisted in a data transfer object, does that make my domain model a wrapper around the…
19
votes
2 answers

Where to define the interfaces for a repository in an layered architecture?

Background I'm trying to create a simple application to really understand the whole stack of DDD+TDD+etc. My goal is to dynamically inject the DAL repository classes at runtime. This keeps my Domain and Application Services layers testable. I…
19
votes
3 answers

Structure of a single bounded context

Does bounded context span over all application layers (domain, application, presentation & infrastructure) or just domain model? For example should i use the following structure: |_ domain |_ application |_ presentation |_…
gseric
  • 649
  • 4
  • 11
19
votes
2 answers

Who should handle the conditions in complex queries, the data mapper or the service layer?

this question did a very good job of clearing my confusion a bit on the matter, but I'm having a hard time finding reliable sources on what the exact limitations of the service layer should be. For this example, assume we're dealing with books, and…
orourkek
  • 2,091
  • 15
  • 22
18
votes
9 answers

DDD: Primary keys (Ids) and ORMs (for example, NHibernate)

Why is it considered OK to have an Id field in the domain entities? I have seen several solutions that provide base class with Id and Id-based GetHashCode/Equals. My understanding of domain model is that it should contain only things related to the…
Andrey Shchekin
  • 21,101
  • 19
  • 94
  • 162
18
votes
4 answers

In DDD where to keep custom exceptions (application exceptions)? In Infrastructure layer?

I'm building a app with following architecture: UI - Application - Domain - Infrastructure I have a Application Layer that need use custom exceptions. Where I keep these custom exceptions? In Infrastructure layer? The problem is my Application Layer…
Acaz Souza
  • 8,311
  • 11
  • 54
  • 97
18
votes
2 answers

Domain Driven Design - Domain model vs Hibernate Entity

Are Hibernate Entities the same as the domain models? See the following example. Method 1 - Domain model and Entity are same class. Domain model "is-an" entity @Entity @Table(name = "agent") class Agent { @Id @GeneratedValue(strategy =…
Vino
  • 2,111
  • 4
  • 22
  • 42
18
votes
4 answers

Domain Entities, DTO, and View Models

I have an ASP.NET MVC 2 application with a POCO domain model and an NHibernate repository layer. My domain model has no awareness of my viewmodels so I use automapper to go from viewmodel to entity and vice/versa. When I introduced WCF to my…
Mayo
  • 10,544
  • 6
  • 45
  • 90
18
votes
3 answers

How do you handle associations between aggregates in DDD?

I'm still wrapping my head around DDD, and one of the stumbling blocks I've encountered is in how to handle associations between separate aggregates. Say I've got one aggregate encapsulating Customers and another encapsulating Shipments. For…
Erik Forbes
  • 35,357
  • 27
  • 98
  • 122
18
votes
3 answers

Entity Framework as Repository and UnitOfWork?

I'm starting a new project and have decided to try to incorporate DDD patterns and also include Linq to Entities. When I look at the EF's ObjectContext it seems to be performing the functions of both Repository and Unit of Work patterns: Repository…
Weej
  • 1,012
  • 2
  • 8
  • 24