DDD Using Specification pattern for Validation

Although you may use your Specifications classes for validation, I would suggest you keep them as separate concepts within your domain. You may find that you need to re-use the same underlying specifications but need to return different “Failure Reasons” depending on purpose and context. See this article for more details. The author of the … Read more

Is it ok for entities to access repositories?

it’s not a horrible violation of DDD it’s a horrible violation of… well… it’s just plain horrible (i say this tongue in cheek) :). First off, your entity becomes dependent on having a repository… that’s not ideal. Ideally you’d want to have your repository create the Person and then assign it everything it needs to … Read more

How to Organise a Domain Driven Design Project?

I try to keep things very simple whenever I can, so usually something like this works for me: Myapp.Domain – All domain specific classes share this namespace Myapp.Data – Thin layer that abstracts the database from the domain. Myapp.Application – All “support code”, logging, shared utility code, service consumers etc Myapp.Web – The web UI … Read more

What Belongs to the Aggregate Root

After doing even MORE research, I think I have the answer to my question. Paul Stovell had this slightly edited response to a similar question on the DDD messageboard. Substitute “Customer” for “Employee”, and “Order” for “Violation” and you get the idea. Just because Customer references Order doesn’t necessarily mean Order falls within the Customer … Read more

Event Sourcing and Read Model generation

Personally I think there’s nothing wrong with looking up the user’s name from within the event handler. But if you’re in a position where you can’t query the name from the User’s read model then I’d introduce an additional event handler to QuestionEventsHandler, to handle the UserRegistered event. That way the QuestionEventsHandler could maintain its … Read more

Communicating between two Bounded Contexts in DDD

When integrating BCs, you have a few options. The reason that calling out to an external BC is discouraged is because it requires for both BCs to be operational at the same time. However, this is often quite acceptable and is simpler than the alternative. An alternative is to have the Game BC subscribe to … Read more

DDD: do I really need to load all objects in an aggregate? (Performance concerns)

Take a look at this Effective Aggregate Design series of three articles from Vernon. I found them quite useful to understand when and how you can design smaller aggregates rather than a large-cluster aggregate. EDIT I would like to give a couple of examples to improve my previous answer, feel free to share your thoughts … Read more

What’s the difference between Data Modelling and Domain Modelling?

Good question, the problem is that it depends on the definion of the terms, I think they differ slightly based on the sources. I would agree with previous answer – domain models are for describing the problem domain, at least the part you need to develop a solution. You describe all the various entities, their … Read more

What are the benefits of Persistence Ignorance?

Let me explain this with an example. Lets assume your are implementing an application using a classical SQL approach. You open recordsets, change data and commit it. Pseudo code: trx = connection.CreateTransaction(); query = connection.CreateQuery(“Select * from Employee where id = empid”); resultset = query.Run(); resultset.SetValue(“Address_Street”, “Bahnhofstrasse”); resultset.SetValue(“Address_City”, “Zürich”); trx.Commit(); With NHibernate it would look … Read more

tech