Where are the DDD sample applications?

It’s a question I see quite a bit, on the ALT.NET mailing list, the DDD mailing list, and any other medium where DDD comes up.  For those trying DDD, this is a rather difficult question to answer.  Many have tried to create DDD how-to’s and samples, including Jimmy Nilsson in his book.  The problem with these examples are twofold:

  • They only show the code-level software patterns
  • DDD isn’t defined as a specific architecture or a specific set of software patterns

There are plenty of software patterns described in Evans’ book.  Entity, Aggregates, Value Object, Aggregate Root, Services, Repositories, Factories and so on.  But merely applying these patterns misses the point, it’s (sigh) cargo cult DDD.

DDD is first and foremost about a model expressed as software.  Businesses have processes and tasks they do, and DDD attempts to bridge the gap between developer and domain expert by applying patterns that help transfer a model of reality into code.  Techniques like Ubiquitous Language attempt to reduce the amount of translation between software model and conceptual model.  Building a robust Ubiquitous Language requires extensive conversations and learning on the part of the developer.

And therein lies the rub.  A finished application does not capture the journey.  It does not capture the conversation.  It captures the final product of learning and application, but not the road to get there.  It does not capture brainstorming or whiteboarding sessions.  It does not capture (well) major decisions and their effects on the model.  Without this journey, the value of the destination is severely diminished.

In Evans’ book, he goes into fairly deep discussion about the domain his examples use.  He also provides sample conversations, sample whiteboarding, and sample modeling sessions.  Some of these are reflections of real conversations and real events.  If you’re looking for a DDD example, it’s Evans’ DDD book.

However, if you’re looking for technical examples of the Repository pattern, ask for that instead.  If you Google “repository pattern” or look for NHibernate examples, you’ll find plenty of resources on how to apply the technical patterns.  Keep in mind that using the Repository pattern does not equate to practicing DDD.  And those who (at least believe) they understand what DDD is all about, a request for DDD examples really doesn’t make any sense.

Encapsulation and thinking behaviorally