SlideShare uma empresa Scribd logo
1 de 47
Domain-Driven Design

     Dennis Traub
           @dtraub
     #devspace 2012-10-19
Domain
  A sphere of knowledge, influence, or activity.

  What an organization does and the world it does it in.
Model
  A system of abstractions that describes selected
  aspects of a Domain and can be used to solve
  problems related to that Domain.
don‘t model reality
we model useful abstractions of
reality
Ubiquitous Language
  A Language structured around the Domain Model
  and used by all team mebers.
Bounded Context
  An explicit Boundary within which a Domain
  Model exists.

  Inside the boundary all terms have specific meaning.
  They are part of the context‘s Ubiquitous Language.
BC Example: Online-Shop
  E-Commerce-System
  Inventory System
  Accounting
Subdomains
  The whole Domain of the organization is comprised
  of Subdomains.

  They focus on only one specific area of the whole
  business Domain.
Subdomain Example:
  Product Catalog
  Customer Management
  Orders
  Invoicing
  Inventory
  Shipping
don‘t build a model that
works for everyone
Core Domain
  The distinctive part of the Model, central to the user‘s
  goals, that differentiates the application and makes it
  valuable.

  The most important Subdomain.
Question # 1:

Which subdomain creates the greatest
competitive advantage?
Question # 2:

Which subdomain has the highest complexity?
we don‘t     use DDD when
there‘s no value in formalizing
the problem
we only use DDD in parts where
we get a competitive advantage
Aggregate
  A cluster of associated objects that are treated as a
  unit for the purpose of data changes.

  A set of consistency rules applies within the
  Aggregate‘s boundaries.
Exercise # 1: A simple Model
  We have Students, Courses, and Teachers
  A Student can take multiple Courses
  A Course can have multiple Students
  A Course is hosted by a Teacher
  A Teacher can host multiple Courses
public class Teacher
{
    public List<Course> Courses { get; private set; }
}


public class Course
{
    public Teacher Teacher { get; private set; }
    public List<Student> Students { get; private set; }
}

public class Student
{
    public List<Course> Courses { get; private set; }
}
Exercise # 2: Assign Teacher
  A Course ist hosted by a Teacher

  Constraint: A Teacher has a maximum number of
  students
public class Teacher
{
    public List<Course> Courses { get; private set; }
    public int MaximumNumberOfStudents { get; private set; }

    public void Assign(Course course) {
        if (course.Students.Count >= MaximumNumberOfStudents)
            throw ...
        this.Courses.Add(course);
        course.AssignTo(this);
    }
}

public class Course
{
    public Teacher Teacher { get; private set; }
    public void AssignTo(Teacher teacher) {
        this.Teachers.Add(teacher);
    }
}
public class Teacher
{
    public List<Course> Courses { get; private set; }
    public int MaximumNumberOfStudents { get; private set; }

    public void Assign(Course course) {
        if (course.Students.Count >= MaximumNumberOfStudents)
            throw ...
        this.Courses.Add(course);
        course.AssignTo(this);
    }
}

public class Course
{
    public Teacher Teacher { get; private set; }
    public void AssignTo(Teacher teacher) {
        this.Teachers.Add(teacher);
    }
}
Pattern # 1: Responsibility

  We don‘t know where to put things.

  Responsibilities must be clear.

  Have one way of doing something, not many.
public class Teacher
{
    public List<Course> Courses { get; private set; }
    public int MaximumNumberOfStudents { get; private set; }

    public void Assign(Course course) {
        if (course.Students.Count >= MaximumNumberOfStudents)
            throw ...
        this.Courses.Add(course);
        // course.AssignTo(this);
        course.Teacher = this;
    }
}

public class Course
{
    public Teacher Teacher { get; private set; }
    /* public void AssignTo(Teacher teacher) {
         this.Teachers.Add(teacher);
    } */
}
public class Teacher
{
    public List<Course> Courses { get; private set; }
    public int MaximumNumberOfStudents { get; private set; }

    public void Assign(Course course) {
        if (course.Students.Count >= MaximumNumberOfStudents)
            throw ...
        this.Courses.Add(course);
        // course.AssignTo(this);
        course.Teacher = this;
    }
}

public class Course
{
    public Teacher Teacher { get; private set; }
    /* public void AssignTo(Teacher teacher) {
         this.Teachers.Add(teacher);
    } */
}
Pattern # 2: Don‘t be stupid
  No rules on Teacher.Courses or Course.Teacher.

  We don‘t need the relationship.
don‘t model reality
public class Teacher
{
    public List<Course> Courses { get; private set; }
    public int MaximumNumberOfStudents { get; private set; }

    /* public void Assign(Course course) {
        if (course.Students.Count >= MaximumNumberOfStudents) throw ...
        this.Courses.Add(course);
        course.AssignTo(this);
    } */
}

public class Course
{
    // public Teacher Teacher { get; private set; }
    public int MaximumNumberOfStudents { get; private set; }

    public void AssignTo(Teacher teacher) {
        if (Students.Count >= teacher.MaximumNumberOfStudents)
            throw ...

        MaximumNumberOfStudents = teacher.MaximumNumberOfStudents;
    }
}
But what if ...
   What happens if the Teacher changes his/her
   maximum number of students?
New Use Case.
Ask the Domain Expert
Exercise # 3: Enroll Student
  A Student can enroll in a Course

  Constraint: A Student can only enroll in up to five
  Courses

  Constraint: A Student‘s Courses may not overlap
public class Course
{
    public int MaximumNumberOfStudents { get; private set; }
    public void Students { get; private set; }

    private void TryEnroll(Student student) {
        if (Students.Count() >= MaximumNumberOfStudents) throw ...
    }

    public void Enroll(Student student) {
        this.TryEnroll(student);
        student.TryEnroll(this);
        this.Students.Add(student);
        student.EnrollIn(this);
    }
}

public class Student
{
    public List<Course> Courses { get; private set; }

    public void TryEnrollIn(Course course) {
        foreach (var c in Courses) {
            if (c.OverlapsWith(course)) throw ...
        }
    }

    public void EnrollIn(Course course) {
        this.Courses.Add(course);
    }
}
public class Course
{
    public int MaximumNumberOfStudents { get; private set; }
    public void Students { get; private set; }

    private void TryEnroll(Student student) {
        if (Students.Count() >= MaximumNumberOfStudents) throw ...
    }

    public void Enroll(Student student) {
        this.TryEnroll(student);
        student.TryEnroll(this);
        this.Students.Add(student);
        student.EnrollIn(this);
    }
}

public class Student
{
    public List<Course> Courses { get; private set; }

    public void TryEnrollIn(Course course) {
        foreach (var c in Courses) {
            if (c.OverlapsWith(course)) throw ...
        }
    }

    public void EnrollIn(Course course) {
        this.Courses.Add(course);
    }
}
Pattern # 3: Capture Concepts
  We‘re missing an explicit concept:
  A Student has a Schedule
  The Schedule consists of Enrollments
  Constraint: Enrollments may not overlap
  Constraint: A Schedule may contain up to 5
  Enrollments
public class Course
{
    public int MaximumNumberOfStudents { get; private set; }
    public void Students { get; private set; }

    private void TryEnroll(Student student) {
        if (Students.Count() >= MaximumNumberOfStudents) throw ...
    }

    internal void Enroll(Student student) {
        // this.TryEnroll(student);
        // student.TryEnroll(this);
        this.Students.Add(student);
        // student.EnrollIn(this);
    }
}

public class Student
{
    public List<Course> Courses { get; private set; }
    public Schedule Schedule { get; private set; }

    public void EnrollIn(Course course) {
        var enrollment = course.CreateEnrollment(course);
        Schedule.TryAddEnrollment(enrollment);
        course.TryEnroll(this);
        Schedule.AddEnrollment(enrollment);
        course.Enroll(this);
    }
}
public class Course
{
    public int MaximumNumberOfStudents { get; private set; }
    // public void Students { get; private set; }
    public int NumberOfStudents { get; private set; }

    private void TryEnroll(Student student) {
        // if (Students.Count() >= MaximumNumberOfStudents) throw ...
        if (NumberOfStudents >= MaximumNumberOfStudents) throw ...
    }

    internal void Enroll(Student student) {
        this.NumberOfStudents++;
    }
}

public class Student
{
    public List<Course> Courses { get; private set; }
    public Schedule Schedule { get; private set; }

    public void EnrollIn(Course course) {
        var enrollment = course.CreateEnrollment(course);
        Schedule.TryAddEnrollment(enrollment);
        course.TryEnroll(this);
        Schedule.AddEnrollment(enrollment);
        course.Enroll(this);
    }
}
Aggregate
  A cluster of associated objects that are treated as a
  unit for the purpose of data changes.

  A set of consistency rules applies within the
  Aggregate‘s boundaries.
In other words:
  A Transaction should only affect one Aggregate.
What if ...
   ... they don‘t need to be done in one Transaction?

   ... we TryEnroll() but not Enroll()?
How big is the business impact?
Domain Events
  A Domain Event is a full-fledged part of the Domain
  Model, a representation of something that happened
  in the Domain.

  Something happened that Domain Experts care
  about, e.g. a Student enrolled in a Course.
public class Course
{
    public int MaximumNumberOfStudents { get; private set; }
    public int NumberOfStudents { get; private set; }

    private void TryEnroll(Student student) {
        if (NumberOfStudents >= MaximumNumberOfStudents) throw ...
    }

    /* public void Enroll(Student student) {
         this.NumberOfStudents++;
    } */

    public void Handle(StudentEnrolledInCourse event) {
        this.NumberOfStudents++;
    }
}

public class Student
{
    public List<Course> Courses { get; private set; }
    public Schedule Schedule { get; private set; }

    public void EnrollIn(Course course) {
        var enrollment = course.CreateEnrollment(course);
        Schedule.TryAddEnrollment(enrollment);
        course.TryEnroll(this);
        Schedule.AddEnrollment(enrollment);
        // course.Enroll(this);
        Bus.Publish(new StudentEnrolledInCourse( ... ));
    }
}
But, once again, what if ...
   ... the Student drops out of a Course?
New Use Case.
Ask the Domain Expert
1. don‘t be stupid

2. denormalize

3. break up consistencies
References & Further Reading:
  Inspiration for the exercises: The works of Greg Young

  Domain-Driven Design – Tackling Complexity in the Heart of Software,
  by Eric Evans, Addison-Wesley, 2004
  Implementing Domain-Driven Design by Vaughn Vernon, Addison-Wesley, 2012
  http://domaindrivendesign.org - DDD-Forum maintained by Eric Evans, et al.
  Effective Aggregate Design: bit.ly/ncCOTH
  Google Group: groups.google.com/forum/?fromgroups#!forum/dddcqrs
Dennis Traub

  @dtraub

 #devspace

Mais conteúdo relacionado

Mais procurados

9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in javaNilesh Dalvi
 
What is the best full text search engine for Python?
What is the best full text search engine for Python?What is the best full text search engine for Python?
What is the best full text search engine for Python?Andrii Soldatenko
 
Machine Learning Algorithm - Decision Trees
Machine Learning Algorithm - Decision Trees Machine Learning Algorithm - Decision Trees
Machine Learning Algorithm - Decision Trees Kush Kulshrestha
 
Manipulação de datas em java
Manipulação de datas em javaManipulação de datas em java
Manipulação de datas em javaNorton Guimarães
 
Conférence: Catalyseurs de l'Intelligence Artificielle et Écosystème des Fram...
Conférence: Catalyseurs de l'Intelligence Artificielle et Écosystème des Fram...Conférence: Catalyseurs de l'Intelligence Artificielle et Écosystème des Fram...
Conférence: Catalyseurs de l'Intelligence Artificielle et Écosystème des Fram...ENSET, Université Hassan II Casablanca
 
Support de cours EJB 3 version complète Par Mr Youssfi, ENSET, Université Ha...
Support de cours EJB 3 version complète Par Mr  Youssfi, ENSET, Université Ha...Support de cours EJB 3 version complète Par Mr  Youssfi, ENSET, Université Ha...
Support de cours EJB 3 version complète Par Mr Youssfi, ENSET, Université Ha...ENSET, Université Hassan II Casablanca
 
Inheritance in c++
Inheritance in c++ Inheritance in c++
Inheritance in c++ sandeep54552
 
Amazon DocumentDB vs MongoDB 의 내부 아키텍쳐 와 장단점 비교
Amazon DocumentDB vs MongoDB 의 내부 아키텍쳐 와 장단점 비교Amazon DocumentDB vs MongoDB 의 내부 아키텍쳐 와 장단점 비교
Amazon DocumentDB vs MongoDB 의 내부 아키텍쳐 와 장단점 비교Amazon Web Services Korea
 
Command Design Pattern
Command Design PatternCommand Design Pattern
Command Design PatternShahriar Hyder
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - CoreDzmitry Naskou
 
Nested List Comprehension and Binary Search
Nested List Comprehension and Binary SearchNested List Comprehension and Binary Search
Nested List Comprehension and Binary SearchColin Su
 
Scaling SolrCloud to a Large Number of Collections - Fifth Elephant 2014
Scaling SolrCloud to a Large Number of Collections - Fifth Elephant 2014Scaling SolrCloud to a Large Number of Collections - Fifth Elephant 2014
Scaling SolrCloud to a Large Number of Collections - Fifth Elephant 2014Shalin Shekhar Mangar
 
Alphorm.com-Formation MongoDB Administration
Alphorm.com-Formation MongoDB AdministrationAlphorm.com-Formation MongoDB Administration
Alphorm.com-Formation MongoDB AdministrationAlphorm
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentationVan Huong
 
Java Strings Tutorial | String Manipulation in Java | Java Tutorial For Begin...
Java Strings Tutorial | String Manipulation in Java | Java Tutorial For Begin...Java Strings Tutorial | String Manipulation in Java | Java Tutorial For Begin...
Java Strings Tutorial | String Manipulation in Java | Java Tutorial For Begin...Edureka!
 

Mais procurados (20)

9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in java
 
What is the best full text search engine for Python?
What is the best full text search engine for Python?What is the best full text search engine for Python?
What is the best full text search engine for Python?
 
Machine Learning Algorithm - Decision Trees
Machine Learning Algorithm - Decision Trees Machine Learning Algorithm - Decision Trees
Machine Learning Algorithm - Decision Trees
 
Manipulação de datas em java
Manipulação de datas em javaManipulação de datas em java
Manipulação de datas em java
 
Conférence: Catalyseurs de l'Intelligence Artificielle et Écosystème des Fram...
Conférence: Catalyseurs de l'Intelligence Artificielle et Écosystème des Fram...Conférence: Catalyseurs de l'Intelligence Artificielle et Écosystème des Fram...
Conférence: Catalyseurs de l'Intelligence Artificielle et Écosystème des Fram...
 
Support de cours EJB 3 version complète Par Mr Youssfi, ENSET, Université Ha...
Support de cours EJB 3 version complète Par Mr  Youssfi, ENSET, Université Ha...Support de cours EJB 3 version complète Par Mr  Youssfi, ENSET, Université Ha...
Support de cours EJB 3 version complète Par Mr Youssfi, ENSET, Université Ha...
 
Inheritance in c++
Inheritance in c++ Inheritance in c++
Inheritance in c++
 
Amazon DocumentDB vs MongoDB 의 내부 아키텍쳐 와 장단점 비교
Amazon DocumentDB vs MongoDB 의 내부 아키텍쳐 와 장단점 비교Amazon DocumentDB vs MongoDB 의 내부 아키텍쳐 와 장단점 비교
Amazon DocumentDB vs MongoDB 의 내부 아키텍쳐 와 장단점 비교
 
Scala Intro
Scala IntroScala Intro
Scala Intro
 
Struts
StrutsStruts
Struts
 
Support de cours technologie et application m.youssfi
Support de cours technologie et application m.youssfiSupport de cours technologie et application m.youssfi
Support de cours technologie et application m.youssfi
 
Java collections notes
Java collections notesJava collections notes
Java collections notes
 
Command Design Pattern
Command Design PatternCommand Design Pattern
Command Design Pattern
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
 
Nested List Comprehension and Binary Search
Nested List Comprehension and Binary SearchNested List Comprehension and Binary Search
Nested List Comprehension and Binary Search
 
Scaling SolrCloud to a Large Number of Collections - Fifth Elephant 2014
Scaling SolrCloud to a Large Number of Collections - Fifth Elephant 2014Scaling SolrCloud to a Large Number of Collections - Fifth Elephant 2014
Scaling SolrCloud to a Large Number of Collections - Fifth Elephant 2014
 
Java reflection
Java reflectionJava reflection
Java reflection
 
Alphorm.com-Formation MongoDB Administration
Alphorm.com-Formation MongoDB AdministrationAlphorm.com-Formation MongoDB Administration
Alphorm.com-Formation MongoDB Administration
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentation
 
Java Strings Tutorial | String Manipulation in Java | Java Tutorial For Begin...
Java Strings Tutorial | String Manipulation in Java | Java Tutorial For Begin...Java Strings Tutorial | String Manipulation in Java | Java Tutorial For Begin...
Java Strings Tutorial | String Manipulation in Java | Java Tutorial For Begin...
 

Semelhante a DDD Modeling Workshop

Starting with Main.java, where I tested everythingimport College..pdf
Starting with Main.java, where I tested everythingimport College..pdfStarting with Main.java, where I tested everythingimport College..pdf
Starting with Main.java, where I tested everythingimport College..pdfaptind
 
import school.; import school.courses.;public class Main { p.pdf
import school.; import school.courses.;public class Main { p.pdfimport school.; import school.courses.;public class Main { p.pdf
import school.; import school.courses.;public class Main { p.pdfannaiwatertreatment
 
C# Delegates, Events, Lambda
C# Delegates, Events, LambdaC# Delegates, Events, Lambda
C# Delegates, Events, LambdaJussi Pohjolainen
 
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo....NET Conf UY
 
Assignment 7
Assignment 7Assignment 7
Assignment 7IIUM
 
C# Summer course - Lecture 4
C# Summer course - Lecture 4C# Summer course - Lecture 4
C# Summer course - Lecture 4mohamedsamyali
 
Refactoring - Mejorando el diseño del código existente
Refactoring - Mejorando el diseño del código existenteRefactoring - Mejorando el diseño del código existente
Refactoring - Mejorando el diseño del código existenteMariano Sánchez
 
A457405934_21789_26_2018_Inheritance.ppt
A457405934_21789_26_2018_Inheritance.pptA457405934_21789_26_2018_Inheritance.ppt
A457405934_21789_26_2018_Inheritance.pptRithwikRanjan
 
Cs141 mid termexam2_fall2017_v1.1_solution
Cs141 mid termexam2_fall2017_v1.1_solutionCs141 mid termexam2_fall2017_v1.1_solution
Cs141 mid termexam2_fall2017_v1.1_solutionFahadaio
 
Inheritance, polymorphisam, abstract classes and composition)
Inheritance, polymorphisam, abstract classes and composition)Inheritance, polymorphisam, abstract classes and composition)
Inheritance, polymorphisam, abstract classes and composition)farhan amjad
 
classes & objects.ppt
classes & objects.pptclasses & objects.ppt
classes & objects.pptBArulmozhi
 
[PL] O klasycznej, programistycznej elegancji
[PL] O klasycznej, programistycznej elegancji[PL] O klasycznej, programistycznej elegancji
[PL] O klasycznej, programistycznej elegancjiJakub Marchwicki
 
Hello. Im currently working on the last section to my assignment a.pdf
Hello. Im currently working on the last section to my assignment a.pdfHello. Im currently working on the last section to my assignment a.pdf
Hello. Im currently working on the last section to my assignment a.pdfirshadkumar3
 
Effective java-3rd-edition-ch4
Effective java-3rd-edition-ch4Effective java-3rd-edition-ch4
Effective java-3rd-edition-ch4Matt
 

Semelhante a DDD Modeling Workshop (20)

Starting with Main.java, where I tested everythingimport College..pdf
Starting with Main.java, where I tested everythingimport College..pdfStarting with Main.java, where I tested everythingimport College..pdf
Starting with Main.java, where I tested everythingimport College..pdf
 
import school.; import school.courses.;public class Main { p.pdf
import school.; import school.courses.;public class Main { p.pdfimport school.; import school.courses.;public class Main { p.pdf
import school.; import school.courses.;public class Main { p.pdf
 
C# Delegates, Events, Lambda
C# Delegates, Events, LambdaC# Delegates, Events, Lambda
C# Delegates, Events, Lambda
 
Mapeamento uml java
Mapeamento uml javaMapeamento uml java
Mapeamento uml java
 
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
 
Jar chapter 5_part_i
Jar chapter 5_part_iJar chapter 5_part_i
Jar chapter 5_part_i
 
Assignment 7
Assignment 7Assignment 7
Assignment 7
 
C# Summer course - Lecture 4
C# Summer course - Lecture 4C# Summer course - Lecture 4
C# Summer course - Lecture 4
 
6 class design
6 class design6 class design
6 class design
 
Refactoring - Mejorando el diseño del código existente
Refactoring - Mejorando el diseño del código existenteRefactoring - Mejorando el diseño del código existente
Refactoring - Mejorando el diseño del código existente
 
A457405934_21789_26_2018_Inheritance.ppt
A457405934_21789_26_2018_Inheritance.pptA457405934_21789_26_2018_Inheritance.ppt
A457405934_21789_26_2018_Inheritance.ppt
 
Cs141 mid termexam2_fall2017_v1.1_solution
Cs141 mid termexam2_fall2017_v1.1_solutionCs141 mid termexam2_fall2017_v1.1_solution
Cs141 mid termexam2_fall2017_v1.1_solution
 
Core java oop
Core java oopCore java oop
Core java oop
 
Inheritance, polymorphisam, abstract classes and composition)
Inheritance, polymorphisam, abstract classes and composition)Inheritance, polymorphisam, abstract classes and composition)
Inheritance, polymorphisam, abstract classes and composition)
 
Lecture 4 part 1.pdf
Lecture 4 part 1.pdfLecture 4 part 1.pdf
Lecture 4 part 1.pdf
 
classes & objects.ppt
classes & objects.pptclasses & objects.ppt
classes & objects.ppt
 
[PL] O klasycznej, programistycznej elegancji
[PL] O klasycznej, programistycznej elegancji[PL] O klasycznej, programistycznej elegancji
[PL] O klasycznej, programistycznej elegancji
 
Hello. Im currently working on the last section to my assignment a.pdf
Hello. Im currently working on the last section to my assignment a.pdfHello. Im currently working on the last section to my assignment a.pdf
Hello. Im currently working on the last section to my assignment a.pdf
 
Object oriented concepts
Object oriented conceptsObject oriented concepts
Object oriented concepts
 
Effective java-3rd-edition-ch4
Effective java-3rd-edition-ch4Effective java-3rd-edition-ch4
Effective java-3rd-edition-ch4
 

Mais de Dennis Traub

Application Integration Patterns (not only) for Microservices
Application Integration Patterns (not only) for MicroservicesApplication Integration Patterns (not only) for Microservices
Application Integration Patterns (not only) for MicroservicesDennis Traub
 
Serverless SecOps Automation on AWS at AWS UG Krakow, Poland
Serverless SecOps Automation on AWS at AWS UG Krakow, PolandServerless SecOps Automation on AWS at AWS UG Krakow, Poland
Serverless SecOps Automation on AWS at AWS UG Krakow, PolandDennis Traub
 
Serverless Security Automation on AWS - Hamburg AWS User Group
Serverless Security Automation on AWS - Hamburg AWS User GroupServerless Security Automation on AWS - Hamburg AWS User Group
Serverless Security Automation on AWS - Hamburg AWS User GroupDennis Traub
 
Cloud ist keine Strategie - Keynote des AWS Cloud Day, Solingen
Cloud ist keine Strategie - Keynote des AWS Cloud Day, SolingenCloud ist keine Strategie - Keynote des AWS Cloud Day, Solingen
Cloud ist keine Strategie - Keynote des AWS Cloud Day, SolingenDennis Traub
 
Cloud ist keine Strategie - AWS Tech Community Summit Cologne, 2017
Cloud ist keine Strategie - AWS Tech Community Summit Cologne, 2017Cloud ist keine Strategie - AWS Tech Community Summit Cologne, 2017
Cloud ist keine Strategie - AWS Tech Community Summit Cologne, 2017Dennis Traub
 
Taming the Monolith - Microservices Meetup Hamburg
Taming the Monolith - Microservices Meetup HamburgTaming the Monolith - Microservices Meetup Hamburg
Taming the Monolith - Microservices Meetup HamburgDennis Traub
 
Taming the Monolith
Taming the MonolithTaming the Monolith
Taming the MonolithDennis Traub
 
DDD / Microservices @ Trivento Spring Camp, Utrecht, 2015
DDD / Microservices @ Trivento Spring Camp, Utrecht, 2015DDD / Microservices @ Trivento Spring Camp, Utrecht, 2015
DDD / Microservices @ Trivento Spring Camp, Utrecht, 2015Dennis Traub
 
Strategic Appplication Development with Domain-Driven Design (DDD)
Strategic Appplication Development with Domain-Driven Design (DDD)Strategic Appplication Development with Domain-Driven Design (DDD)
Strategic Appplication Development with Domain-Driven Design (DDD)Dennis Traub
 
An Introduction to CQRS
An Introduction to CQRSAn Introduction to CQRS
An Introduction to CQRSDennis Traub
 
Strategischer Anwendungsentwurf mit Domain-Driven Design
Strategischer Anwendungsentwurf mit Domain-Driven DesignStrategischer Anwendungsentwurf mit Domain-Driven Design
Strategischer Anwendungsentwurf mit Domain-Driven DesignDennis Traub
 
CQRS-Einführung - Teil 2
CQRS-Einführung - Teil 2CQRS-Einführung - Teil 2
CQRS-Einführung - Teil 2Dennis Traub
 
CQRS - Eine Einführung - NOUG 2011
CQRS - Eine Einführung - NOUG 2011CQRS - Eine Einführung - NOUG 2011
CQRS - Eine Einführung - NOUG 2011Dennis Traub
 

Mais de Dennis Traub (14)

Application Integration Patterns (not only) for Microservices
Application Integration Patterns (not only) for MicroservicesApplication Integration Patterns (not only) for Microservices
Application Integration Patterns (not only) for Microservices
 
Serverless SecOps Automation on AWS at AWS UG Krakow, Poland
Serverless SecOps Automation on AWS at AWS UG Krakow, PolandServerless SecOps Automation on AWS at AWS UG Krakow, Poland
Serverless SecOps Automation on AWS at AWS UG Krakow, Poland
 
Serverless Security Automation on AWS - Hamburg AWS User Group
Serverless Security Automation on AWS - Hamburg AWS User GroupServerless Security Automation on AWS - Hamburg AWS User Group
Serverless Security Automation on AWS - Hamburg AWS User Group
 
Cloud ist keine Strategie - Keynote des AWS Cloud Day, Solingen
Cloud ist keine Strategie - Keynote des AWS Cloud Day, SolingenCloud ist keine Strategie - Keynote des AWS Cloud Day, Solingen
Cloud ist keine Strategie - Keynote des AWS Cloud Day, Solingen
 
Cloud ist keine Strategie - AWS Tech Community Summit Cologne, 2017
Cloud ist keine Strategie - AWS Tech Community Summit Cologne, 2017Cloud ist keine Strategie - AWS Tech Community Summit Cologne, 2017
Cloud ist keine Strategie - AWS Tech Community Summit Cologne, 2017
 
Taming the Monolith - Microservices Meetup Hamburg
Taming the Monolith - Microservices Meetup HamburgTaming the Monolith - Microservices Meetup Hamburg
Taming the Monolith - Microservices Meetup Hamburg
 
Taming the Monolith
Taming the MonolithTaming the Monolith
Taming the Monolith
 
DDD / Microservices @ Trivento Spring Camp, Utrecht, 2015
DDD / Microservices @ Trivento Spring Camp, Utrecht, 2015DDD / Microservices @ Trivento Spring Camp, Utrecht, 2015
DDD / Microservices @ Trivento Spring Camp, Utrecht, 2015
 
Strategic Appplication Development with Domain-Driven Design (DDD)
Strategic Appplication Development with Domain-Driven Design (DDD)Strategic Appplication Development with Domain-Driven Design (DDD)
Strategic Appplication Development with Domain-Driven Design (DDD)
 
An Introduction to CQRS
An Introduction to CQRSAn Introduction to CQRS
An Introduction to CQRS
 
From DDD to CQRS
From DDD to CQRSFrom DDD to CQRS
From DDD to CQRS
 
Strategischer Anwendungsentwurf mit Domain-Driven Design
Strategischer Anwendungsentwurf mit Domain-Driven DesignStrategischer Anwendungsentwurf mit Domain-Driven Design
Strategischer Anwendungsentwurf mit Domain-Driven Design
 
CQRS-Einführung - Teil 2
CQRS-Einführung - Teil 2CQRS-Einführung - Teil 2
CQRS-Einführung - Teil 2
 
CQRS - Eine Einführung - NOUG 2011
CQRS - Eine Einführung - NOUG 2011CQRS - Eine Einführung - NOUG 2011
CQRS - Eine Einführung - NOUG 2011
 

Último

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 

Último (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

DDD Modeling Workshop

  • 1. Domain-Driven Design Dennis Traub @dtraub #devspace 2012-10-19
  • 2. Domain A sphere of knowledge, influence, or activity. What an organization does and the world it does it in.
  • 3. Model A system of abstractions that describes selected aspects of a Domain and can be used to solve problems related to that Domain.
  • 5. we model useful abstractions of reality
  • 6. Ubiquitous Language A Language structured around the Domain Model and used by all team mebers.
  • 7. Bounded Context An explicit Boundary within which a Domain Model exists. Inside the boundary all terms have specific meaning. They are part of the context‘s Ubiquitous Language.
  • 8. BC Example: Online-Shop E-Commerce-System Inventory System Accounting
  • 9. Subdomains The whole Domain of the organization is comprised of Subdomains. They focus on only one specific area of the whole business Domain.
  • 10. Subdomain Example: Product Catalog Customer Management Orders Invoicing Inventory Shipping
  • 11. don‘t build a model that works for everyone
  • 12. Core Domain The distinctive part of the Model, central to the user‘s goals, that differentiates the application and makes it valuable. The most important Subdomain.
  • 13. Question # 1: Which subdomain creates the greatest competitive advantage?
  • 14. Question # 2: Which subdomain has the highest complexity?
  • 15. we don‘t use DDD when there‘s no value in formalizing the problem
  • 16. we only use DDD in parts where we get a competitive advantage
  • 17. Aggregate A cluster of associated objects that are treated as a unit for the purpose of data changes. A set of consistency rules applies within the Aggregate‘s boundaries.
  • 18. Exercise # 1: A simple Model We have Students, Courses, and Teachers A Student can take multiple Courses A Course can have multiple Students A Course is hosted by a Teacher A Teacher can host multiple Courses
  • 19. public class Teacher { public List<Course> Courses { get; private set; } } public class Course { public Teacher Teacher { get; private set; } public List<Student> Students { get; private set; } } public class Student { public List<Course> Courses { get; private set; } }
  • 20. Exercise # 2: Assign Teacher A Course ist hosted by a Teacher Constraint: A Teacher has a maximum number of students
  • 21. public class Teacher { public List<Course> Courses { get; private set; } public int MaximumNumberOfStudents { get; private set; } public void Assign(Course course) { if (course.Students.Count >= MaximumNumberOfStudents) throw ... this.Courses.Add(course); course.AssignTo(this); } } public class Course { public Teacher Teacher { get; private set; } public void AssignTo(Teacher teacher) { this.Teachers.Add(teacher); } }
  • 22. public class Teacher { public List<Course> Courses { get; private set; } public int MaximumNumberOfStudents { get; private set; } public void Assign(Course course) { if (course.Students.Count >= MaximumNumberOfStudents) throw ... this.Courses.Add(course); course.AssignTo(this); } } public class Course { public Teacher Teacher { get; private set; } public void AssignTo(Teacher teacher) { this.Teachers.Add(teacher); } }
  • 23. Pattern # 1: Responsibility We don‘t know where to put things. Responsibilities must be clear. Have one way of doing something, not many.
  • 24. public class Teacher { public List<Course> Courses { get; private set; } public int MaximumNumberOfStudents { get; private set; } public void Assign(Course course) { if (course.Students.Count >= MaximumNumberOfStudents) throw ... this.Courses.Add(course); // course.AssignTo(this); course.Teacher = this; } } public class Course { public Teacher Teacher { get; private set; } /* public void AssignTo(Teacher teacher) { this.Teachers.Add(teacher); } */ }
  • 25. public class Teacher { public List<Course> Courses { get; private set; } public int MaximumNumberOfStudents { get; private set; } public void Assign(Course course) { if (course.Students.Count >= MaximumNumberOfStudents) throw ... this.Courses.Add(course); // course.AssignTo(this); course.Teacher = this; } } public class Course { public Teacher Teacher { get; private set; } /* public void AssignTo(Teacher teacher) { this.Teachers.Add(teacher); } */ }
  • 26. Pattern # 2: Don‘t be stupid No rules on Teacher.Courses or Course.Teacher. We don‘t need the relationship.
  • 28. public class Teacher { public List<Course> Courses { get; private set; } public int MaximumNumberOfStudents { get; private set; } /* public void Assign(Course course) { if (course.Students.Count >= MaximumNumberOfStudents) throw ... this.Courses.Add(course); course.AssignTo(this); } */ } public class Course { // public Teacher Teacher { get; private set; } public int MaximumNumberOfStudents { get; private set; } public void AssignTo(Teacher teacher) { if (Students.Count >= teacher.MaximumNumberOfStudents) throw ... MaximumNumberOfStudents = teacher.MaximumNumberOfStudents; } }
  • 29. But what if ... What happens if the Teacher changes his/her maximum number of students?
  • 30. New Use Case. Ask the Domain Expert
  • 31. Exercise # 3: Enroll Student A Student can enroll in a Course Constraint: A Student can only enroll in up to five Courses Constraint: A Student‘s Courses may not overlap
  • 32. public class Course { public int MaximumNumberOfStudents { get; private set; } public void Students { get; private set; } private void TryEnroll(Student student) { if (Students.Count() >= MaximumNumberOfStudents) throw ... } public void Enroll(Student student) { this.TryEnroll(student); student.TryEnroll(this); this.Students.Add(student); student.EnrollIn(this); } } public class Student { public List<Course> Courses { get; private set; } public void TryEnrollIn(Course course) { foreach (var c in Courses) { if (c.OverlapsWith(course)) throw ... } } public void EnrollIn(Course course) { this.Courses.Add(course); } }
  • 33. public class Course { public int MaximumNumberOfStudents { get; private set; } public void Students { get; private set; } private void TryEnroll(Student student) { if (Students.Count() >= MaximumNumberOfStudents) throw ... } public void Enroll(Student student) { this.TryEnroll(student); student.TryEnroll(this); this.Students.Add(student); student.EnrollIn(this); } } public class Student { public List<Course> Courses { get; private set; } public void TryEnrollIn(Course course) { foreach (var c in Courses) { if (c.OverlapsWith(course)) throw ... } } public void EnrollIn(Course course) { this.Courses.Add(course); } }
  • 34. Pattern # 3: Capture Concepts We‘re missing an explicit concept: A Student has a Schedule The Schedule consists of Enrollments Constraint: Enrollments may not overlap Constraint: A Schedule may contain up to 5 Enrollments
  • 35. public class Course { public int MaximumNumberOfStudents { get; private set; } public void Students { get; private set; } private void TryEnroll(Student student) { if (Students.Count() >= MaximumNumberOfStudents) throw ... } internal void Enroll(Student student) { // this.TryEnroll(student); // student.TryEnroll(this); this.Students.Add(student); // student.EnrollIn(this); } } public class Student { public List<Course> Courses { get; private set; } public Schedule Schedule { get; private set; } public void EnrollIn(Course course) { var enrollment = course.CreateEnrollment(course); Schedule.TryAddEnrollment(enrollment); course.TryEnroll(this); Schedule.AddEnrollment(enrollment); course.Enroll(this); } }
  • 36. public class Course { public int MaximumNumberOfStudents { get; private set; } // public void Students { get; private set; } public int NumberOfStudents { get; private set; } private void TryEnroll(Student student) { // if (Students.Count() >= MaximumNumberOfStudents) throw ... if (NumberOfStudents >= MaximumNumberOfStudents) throw ... } internal void Enroll(Student student) { this.NumberOfStudents++; } } public class Student { public List<Course> Courses { get; private set; } public Schedule Schedule { get; private set; } public void EnrollIn(Course course) { var enrollment = course.CreateEnrollment(course); Schedule.TryAddEnrollment(enrollment); course.TryEnroll(this); Schedule.AddEnrollment(enrollment); course.Enroll(this); } }
  • 37. Aggregate A cluster of associated objects that are treated as a unit for the purpose of data changes. A set of consistency rules applies within the Aggregate‘s boundaries.
  • 38. In other words: A Transaction should only affect one Aggregate.
  • 39. What if ... ... they don‘t need to be done in one Transaction? ... we TryEnroll() but not Enroll()?
  • 40. How big is the business impact?
  • 41. Domain Events A Domain Event is a full-fledged part of the Domain Model, a representation of something that happened in the Domain. Something happened that Domain Experts care about, e.g. a Student enrolled in a Course.
  • 42. public class Course { public int MaximumNumberOfStudents { get; private set; } public int NumberOfStudents { get; private set; } private void TryEnroll(Student student) { if (NumberOfStudents >= MaximumNumberOfStudents) throw ... } /* public void Enroll(Student student) { this.NumberOfStudents++; } */ public void Handle(StudentEnrolledInCourse event) { this.NumberOfStudents++; } } public class Student { public List<Course> Courses { get; private set; } public Schedule Schedule { get; private set; } public void EnrollIn(Course course) { var enrollment = course.CreateEnrollment(course); Schedule.TryAddEnrollment(enrollment); course.TryEnroll(this); Schedule.AddEnrollment(enrollment); // course.Enroll(this); Bus.Publish(new StudentEnrolledInCourse( ... )); } }
  • 43. But, once again, what if ... ... the Student drops out of a Course?
  • 44. New Use Case. Ask the Domain Expert
  • 45. 1. don‘t be stupid 2. denormalize 3. break up consistencies
  • 46. References & Further Reading: Inspiration for the exercises: The works of Greg Young Domain-Driven Design – Tackling Complexity in the Heart of Software, by Eric Evans, Addison-Wesley, 2004 Implementing Domain-Driven Design by Vaughn Vernon, Addison-Wesley, 2012 http://domaindrivendesign.org - DDD-Forum maintained by Eric Evans, et al. Effective Aggregate Design: bit.ly/ncCOTH Google Group: groups.google.com/forum/?fromgroups#!forum/dddcqrs
  • 47. Dennis Traub @dtraub #devspace