427

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 code samples that do a good job of modelling basic DDD concepts?

Particularly interested in

  • An illustrative Domain Model
  • Repositories
  • Use of Domain/Application Services
  • Value Objects
  • Aggregate Roots
6
  • 48
    IHMO such debates will help a lot. Sometimes more than a simple question. E.g. we could change this in a question: "Where do i find some good examples for DDD?" and it works with the Q&A format.
    – Gizzmo
    Commented Oct 10, 2014 at 7:30
  • 2
    i have found the "agile management project" example from Vaughn Vernon's book very instructive. it illustrates practical implementation of the building blocks you enumerate, as well as dealing with different bounded contexts, you can find the code here: github.com/VaughnVernon/IDDD_Samples
    – Mehdi.
    Commented Jun 2, 2015 at 19:25
  • 1
    I would recommend this example: github.com/vkhorikov/DddInAction
    – Vladimir
    Commented Jul 21, 2016 at 21:09
  • 1
    You can have a look here: dzone.com/storage/assets/…
    – Arefe
    Commented Apr 11, 2018 at 12:36
  • Got one here: github.com/appie2go/steal-this-code
    – Clark Kent
    Commented May 6, 2020 at 14:25

7 Answers 7

224

The difficulty with DDD samples is that they're often very domain specific and the technical implementation of the resulting system doesn't always show the design decisions and transitions that were made in modelling the domain, which is really at the core of DDD. DDD is much more about the process than it is the code. (as some say, the best DDD sample is the book itself!)

That said, a well commented sample app should at least reveal some of these decisions and give you some direction in terms of matching up your domain model with the technical patterns used to implement it.

You haven't specified which language you're using, but I'll give you a few in a few different languages:

DDDSample - a Java sample that reflects the examples Eric Evans talks about in his book. This is well commented and shows a number of different methods of solving various problems with separate bounded contexts (ie, the presentation layer). It's being actively worked on, so check it regularly for updates.

dddps - Tim McCarthy's sample C# app for his book, .NET Domain-Driven Design with C#

S#arp Architecture - a pragmatic C# example, not as "pure" a DDD approach perhaps due to its lack of a real domain problem, but still a nice clean approach.

With all of these sample apps, it's probably best to check out the latest trunk versions from SVN/whatever to really get an idea of the thinking and technology patterns as they should be updated regularly.

4
  • 5
    As mentionned @Mehdi in the original question comment you should add the wonderful example from Vaughn Vernon. It is the best implementation of DDD pattern so far I have ever seen: github.com/VaughnVernon/IDDD_Samples Commented Mar 25, 2017 at 14:13
  • I know this is old, but the example from dddps appears to be fully anemic and counter to OOP actually. None of the domain objects have any behavior, and the service layer classes are basically a 1:1 delegation to the repositories. I'm not sure if this should be considered a "good" example of DDD? I'm still learning myself, but the samples in S#arp Architecture seem to be a better example for those learning DDD as it emcompasses both state and behavior, which is good OOP design. Commented Jan 21, 2018 at 17:56
  • You should now add the excellent sample of Vaugnh Vernon the author of Implementing Domain Driven Design (IDDD): github.com/VaughnVernon/IDDD_Samples Commented Jan 24, 2018 at 12:12
  • Any project for c++/c or golang user? Commented Sep 6, 2020 at 23:47
25

Not source projects per say but I stumbled upon Parleys.com which has a few good videos that cover DDD quite well (requires flash):

I found these much more helpful than the almost non-existent DDD examples that are currently available.

1
  • 1
    links not working
    – sidgate
    Commented Mar 2, 2020 at 12:07
15

.NET DDD Sample from Domain-Driven Design Book by Eric Evans can be found here: http://dddsamplenet.codeplex.com

Cheers,

Jakub G

2
  • sadly link is broken
    – Ali Karaca
    Commented Dec 30, 2021 at 12:00
  • yep, after 12 years it might :) CodePlex was shutdown on October 21, 2021
    – Gutek
    Commented Jun 2, 2022 at 11:17
11

Check out Project Silk. Not only does it demonstrate DDD but other cutting edge patterns. This is an excellent resource for any Web Developer. A full overview of the project can be found on MSDN.

1
  • 1
    Source code not available anymore :(
    – Dherik
    Commented Jan 2, 2018 at 11:26
6

This is a good example based on domain driven design and explains why it is important to have separate domain layer.
Microsoft spain - DDD N Layer Architecture

2
  • 2
    I can't vote this down but go to Ayende's blog to see why he thinks this is not a good example. ayende.com/blog/19457/…
    – Chris
    Commented Mar 1, 2013 at 7:08
  • 2
    the link you provide doesn't work, message error: 'Project 'microsoftnlayerapp' was not found' Commented Mar 28, 2019 at 8:10
6

ddd-cqrs-sample is also a good resource. Written with Java, Spring and JPA.

Updated link: https://github.com/BottegaIT/ddd-leaven-v2

5

Code Camp Server, Jeffrey Palermo's sample code for the book ASP.NET MVC in Action. While the book is focused on the presentation layer, the application is modeled using DDD.

Not the answer you're looking for? Browse other questions tagged or ask your own question.