ddd hands on - entwicklertag · 2017-05-27 · inheritance o/r-mapping a b method interface linux...

180
WPS Workplace Solutions #dddkonkret www.wps.de DOMAIN-DRIVEN DESIGN HANDS-ON Henning Schwentner

Upload: others

Post on 06-Jul-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

WPS – Workplace Solutions #dddkonkret www.wps.de

DOMAIN-DRIVEN DESIGN HANDS-ONHenning Schwentner

Page 2: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE
Page 3: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE
Page 4: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

HENNING

Page 5: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 5WPS – Workplace Solutions

SCHWENTNER

Page 6: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE
Page 7: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

@hschwentner

Page 8: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE
Page 9: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE
Page 10: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE
Page 11: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE
Page 12: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

@hschwentner

speakerdeck.com/hschwentner

Page 13: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

Quelle:http://www.schulbilder.org/malvorlage-informatiker-i10418.html

Page 14: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE
Page 15: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

Foto

: H

ennin

g S

chw

entn

er

Page 16: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

Fritz&Franz&Lothar&Philipp.

Page 17: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE
Page 18: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE
Page 19: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE
Page 20: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE
Page 21: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE
Page 22: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE
Page 23: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE
Page 24: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

Wilhelm Paula Siegfried

Foto

: Lo

tse/

Wik

ipoe

dia

Page 25: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

Inhalt

Page 26: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

WorkshopDomain-Driven Designkonkret

wps.de/ddd

Page 27: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 27WPS – Workplace Solutions

Domain Model

Building BlocksDomain EventAggregate

Entity

Value Object

Bounded Context

Strategic Design

Context Mapping

Ubiquitous LanguageDomain Expert

Event Storming

Factory

Tactical Design

Page 28: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 28WPS – Workplace Solutions

MicroservicesCQRS

Hexagonal Architecture

AgileEvent SourcingExtreme Programming

Scrum

Design by Contract

Kanban

Page 29: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

Lesetipps

Page 30: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE
Page 31: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE
Page 32: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE
Page 33: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE
Page 34: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE
Page 35: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 35WPS – Workplace Solutions

VORSTELLUNGSRUNDE

§ Wer bin ich?§ Welche Erfahrung als Entwickler habe ich? Programmiersprachen?§ Was wünsche ich mir von der Schulung?§ Welche Fragen habe ich?§ Was weiß ich schon über DDD?

Page 36: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

WPS – Workplace Solutions #dddkonkret www.wps.de

ÜBERBLICK – WAS IST DOMAIN-DRIVEN DESIGN?Domain-Driven Design konkret

Page 37: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 37WPS – Workplace Solutions

WIR SIND PROGRAMMIERER...

Page 38: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 38WPS – Workplace Solutions

... UND WIR LIEBEN TECHNIK

Page 39: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 39WPS – Workplace Solutions

EINFÜHRUNG

§ Software ist ein Mittel zum Zweck

§ Kein Selbstzweck

§ Das Ziel ist das Ziel

§ Eine produktive Software lässt sich nicht von ihrem Einsatzkontext trennen.§ Ein Softwareprodukt wird durch seine Schöpfer geprägt.

Page 40: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 40WPS – Workplace Solutions

ANWENDER

Page 41: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 41WPS – Workplace Solutions

IN SCHÖNHEIT STERBEN

§ Technische Schönheit wird uns nicht helfen, wenn wir unsere Fachexperten (domain experts) nicht unterstützen

Page 42: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 42WPS – Workplace Solutions

WAS IST DOMAIN-DRIVEN DESIGN?

§ Eine Herangehensweise an die Entwicklung von Software,§ deren zentraler Bestandteil die Implementierung eines Domänenmodells ist.

§ Es vereint§ Entwurf§ Entwicklungspraxis

Page 43: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 43WPS – Workplace Solutions

§ Schreibe Software, die tief in der Domäne verwurzelt ist!

SOFTWARE UND DOMÄNE

Software

Domäne

Page 44: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 44WPS – Workplace Solutions

DOMAIN-DRIVEN DESIGN ANWENDEN

§ Zu Beginn eines Softwareprojekts:§ Fokussiere die Domäne in der die Software eingesetzt wird

§ Wie erschafft man Software, die zu einer Domäne passt?§ Begreife Software als Reflektion

der Domäne§ Lasse Kernkonzepte und

Elemente der Domäne in die Software einfließen

§ Realisiere ihre Zusammenhänge

§ Erstelle ein Domänenmodell

Page 45: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 45WPS – Workplace Solutions

SOFTWARE ALS REFLEKTION DER DOMÄNE

§ Die Dinge aus der Wirklichkeit werden zu Klassen

§ Die Umgangsformen der Dinge werden zu Methoden

èWir wollen Fachliche Modelle mit reichem fachlichem Verhalten

Page 46: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 46WPS – Workplace Solutions

DAS MODELL KOMMUNIZIEREN

§ Das Modell kann nicht nur in unseren Köpfen bestehen

§ Wir müssen Wissen und Informationen verteilen

§ Grafisch§ Schriftlich§ Mündlich

èEine gemeinsame Sprache ist notwendig, umdas Modell ausdrücken zu können

èIn DDD wird diese Allgegenwärtige Sprache(Ubiquitous Language) genannt

Page 47: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 47WPS – Workplace Solutions

TAKTISCHES UND STRATEGISCHES MODELLIEREN

§ DDD gibt Anleitung für Modellierung im Großen und im Kleinen

§ Strategisches Modellieren§ Teile die Domäne in getrennte Bounded Contexts auf§ Jeder BC hat sein eigenes Fachmodell und seine eigene Allgegenwärtige Sprache§ Context Mapping hilft die Beziehungen zwischen Bounded Contexts zu verstehen

§ Taktisches Modellieren§ Innerhalb eines Bounded Context§ Building Blocks: Entity,

Value Object, Aggregate, Repository

Page 48: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

WPS – Workplace Solutions #dddkonkret www.wps.de

EVENT STORMINGDomain-Driven Design konkret

Page 49: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 49WPS – Workplace Solutions

WAS IST EVENT STORMING?

§ Ein Workshopformat§ Eine Methode um

§ Die Domäne kennenzulernen§ Geschäftsprozesse zu modellieren

§ Die Spaß macht

èKeine DiagrammeèKeine TischeèKeine Stühle

@ziobrando

Page 50: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 50WPS – Workplace Solutions

WAS MAN BRAUCHT

§ Die richtigen Leute: Fachexperten und Entwickler§ Einen offenen Geist§ Eine Sammlung Sticker in verschiedenen Farben§ Eine leere Wand die ca. 10 Meter lang ist § Eine lange Rolle Papier, die man auf der Wand befestigen kann

Page 51: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 51WPS – Workplace Solutions

DIE DREI SCHRITTE

1. Erzeuge eine Serie von Fachlichen Ereignissen (Domain Events)2. Erzeuge die Commands, die die Fachlichen Ereignisse verursachen3. Füge die Entity/Aggregate hinzu, auf dem das Command ausgeführt wird

Page 52: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 52WPS – Workplace Solutions

1. ERZEUGE EINE SERIE VON DOMAIN EVENTS

§ Arbeite den Geschäftsprozess als eine Serie von Domänen Ereignissen aus§ Orange Stickies§ Verben in der Vergangenheitsform

§ Relevant für die Fachexperten

Page 53: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 53WPS – Workplace Solutions

1. ERZEUGE EINE SERIE VON DOMAIN EVENTS – BEISPIEL

Page 54: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 54WPS – Workplace Solutions

2. ERZEUGE DIE VERANTWORTLICHEN COMMANDS

§ Für jedes Domain Event erzeugt man einen Command, der ihn verursacht§ Blaue Stickies§ Im Imperativ

§ Die Akteur kommen auf kleine gelbe Stickies

Page 55: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 55WPS – Workplace Solutions

2. ERZEUGE DIE VERANTWORTLICHEN COMMANDS – BEISPIEL

Page 56: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 56WPS – Workplace Solutions

2. ERZEUGE DIE VERANTWORTLICHEN COMMANDS – MIT DEN AKTEUREN

Page 57: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 57WPS – Workplace Solutions

3. DAZUGEHÖRIGE AGGREGATE

§ Ordne das Aggregate oder die Entity dem Command zu, der an ihm ausgeführt wird, und dem Domain Event zu, das es produziert.

§ Helles gelb§ Hinter den Stickies von Command und Domain Event

Page 58: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 58WPS – Workplace Solutions

3. ORDNE ENTITY/AGGREGATE ZU – BEISPIEL

Page 59: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 59WPS – Workplace Solutions

ÜBUNG: EVENT STORMING IM KINO

Page 60: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

WPS – Workplace Solutions #dddkonkret www.wps.de

UBIQUITOUS LANGUAGEDomain-Driven Design konkret

Page 61: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

“There are only two hard things in Computer Science:

cache invalidation and naming things.”

Phil Karlton

Page 62: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

“There are only two hard things in Computer Science:

cache invalidation, naming things,

and off-by-one errors.”

Phil Karlton

Page 63: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 63WPS – Workplace Solutions

TECHNISCHE SPRACHE

X

Class

Database

Server

Client

O/R-MappingInheritance

A

B

Method

Interface

LinuxWindows

Eclipse

Visual Studio

Page 64: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 64WPS – Workplace Solutions

DOMÄNEN-SPRACHE – BEISPIEL SCHIFFAHRT

Container

Containernummer

4300

Kran

Twistlock

Frachtbrief

Page 65: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 65WPS – Workplace Solutions

DOMÄNEN-SPRACHE – BEISPIEL SCHACH

Brett

König

Figuren Spieler

Schachuhr

Page 66: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 66WPS – Workplace Solutions

DOMÄNEN-SPRACHE – BEISPIEL SCHACH II

Remis

Zugzwang

Schachmatt

Spiel

Zug

Rochade

Page 67: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 67WPS – Workplace Solutions

KATEGORISIERUNG ANHAND EINES BEISPIELS

A

B

C

D

E

F

G

• Gruppiere

• Begründe die Gruppierung

Page 68: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 68WPS – Workplace Solutions

Fach-sprache

Techno Babble

?

MOTIVATION ALLGEGENWÄRTIGE SPRACHE

Page 69: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 69WPS – Workplace Solutions

Fach-sprache

Techno Babble

Fach-sprache

MOTIVATION ALLGEGENWÄRTIGE SPRACHE

Page 70: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 70WPS – Workplace Solutions

Fach-sprache

Techno Babble

MOTIVATION ALLGEGENWÄRTIGE SPRACHE

Page 71: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 71WPS – Workplace Solutions

Techno Babble

Fach-sprache

MOTIVATION ALLGEGENWÄRTIGE SPRACHE

Page 72: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 72WPS – Workplace Solutions

Fach-sprache

{Techno Babble}

?

MOTIVATION ALLGEGENWÄRTIGE SPRACHE

Page 73: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 73WPS – Workplace Solutions

Fach-sprache

{Fach-sprache}

MOTIVATION ALLGEGENWÄRTIGE SPRACHE

Page 74: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 74WPS – Workplace Solutions

Allgegen-wärtigeSprache

{Allgegen-wärtigeSprache

}

MOTIVATION ALLGEGENWÄRTIGE SPRACHE

Page 75: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 75WPS – Workplace Solutions

GEMEINSAME SPRACHE

§ Fachexperten verstehen keine Begriffe zu technischen Umsetzungen§ Fachexperten sprechen den Jargon ihrer Domäne, der für Außenstehende wiederum schwer

verständlich sein kann

è Eine gemeinsame Sprache ist notwendig!§ Welche soll es sein?

§ Die der Entwickler?§ Die der Fachexperten?§ Etwas dazwischen?

èPrinzip von DDD: „Verwende eine Sprache die auf dem Domänenmodell basiert“

Page 76: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 76WPS – Workplace Solutions

ALLGEGENWÄRTIGE SPRACHE

§ Verwende die gemeinsame Sprache in..§ der Kommunikation

§ mündlich§ schriftlich§ grafisch

§ im Code

§ Im Grunde genommen überall

è Deswegen nennt sich die Sprache allgegenwärtig.

Page 77: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 77WPS – Workplace Solutions

SPRACHE TAUCHT NICHT EINFACH AUF

§ Es braucht Wochen bis Monate...

§ harter Arbeit§ und scharfem Fokus

§ … um die Schlüsselkonzepte offenzulegen.

§ Die ersten Wörter einer allgegenwärtigen Sprache kommen üblicherweise direkt aus der Domäne

§ Im Laufe der Entwicklung werden neue Begriffe definiert und hinzugefügt

Page 78: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 78WPS – Workplace Solutions

DOMÄNEN-SPRACHE

Brett

König

Figuren

Spieler

Schachuhr

Page 79: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 79WPS – Workplace Solutions

ALLGEGENWÄRTIGE SPRACHE

Brett

Figuren

Spieler

Page 80: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 80WPS – Workplace Solutions

ALLGEGENWÄRTIGE SPRACHE – ITERATION 2

Figuren

Spieler

NichtmenschlicherSpieler

Brett

Page 81: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 81WPS – Workplace Solutions

SPRACHEN SIND LEBENDIG

§ Experimentiere mit alternativen Ausdrucksformen§ Das Modell und die Sprache entwickeln sich weiter

§ Überarbeite dann den Code§ Benenne Klassen, Methoden, Module§ Entspreche dem neuen Modell

§ Eine Sprache will gesprochen werden:§ Beseitige Unklarheiten durch Konversation

Page 82: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 82WPS – Workplace Solutions

GLOSSAR

§ Fachsprache der Benutzer/Ubiquitous Language•bereits existierende Begriffe•rekonstruierte Begriffe•neue Begriffsbildungen

• Wer tut was damit wozu?

§ Kernkonzepte

§ Wichtiger am Anfang des Projektes§ Oft Wegwerfprodukt

Page 83: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 83WPS – Workplace Solutions

GLOSSAR – BEISPIELDOMÄNE SCHACH

König – eine besondere Figur, die nur ein Feld pro Zug bewegt werden kann. Wenn der König schachmatt gesetzt wurde, ist das Spiel vorbei.

Spieler – Einer von zwei Personen, die Figuren auf dem Brett bewegen.

BegriffBeschreibung

Page 84: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 84WPS – Workplace Solutions

FACHLICHE KERNBEGRIFFE IM IST IDENTIFIZIEREN

Kernbegriffe im Kino für ein Glossar identifizierenund oben auf die großen Sticker schreiben.

Page 85: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 85WPS – Workplace Solutions

KERNBEGRIFFE FÜR DAS KINO

Saalplan

Vorstellung

Reservierungs-nummer

Kinokarte

SaalplanstapelListe der Reservierungs-nummern

Gesamtablauf-plan

Tagesablaufplan

Film Platz/Sitzplatz

Saal/Kinosaal

WerbungVeranstaltung

EisverkaufVorführung

?

?

Page 86: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

WPS – Workplace Solutions #dddkonkret www.wps.de

STRATEGISCHES DESIGNDomain-Driven Design konkret

Page 87: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE
Page 88: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 88WPS – Workplace Solutions

MODELLKONSISTENZ

§ Grundsätzliche Anforderung an jedes Domänenmodell: Konsistenz

§ Begriffe haben immer und überall die selbe Bedeutung

§ Keine Widersprüche

§ Vereinheitlichung = Die interne Konsistenz eines Modells

Page 89: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 89WPS – Workplace Solutions

DAS GROSSE VEREINHEITLICHTE MODELL

§ Umfasst die vollständige Domäne eines Unternehmens

èViel zu kompliziertèHoher Koordinationsaufwand in TeamsèFührt oft zu einem big ball of mud

Page 90: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 90WPS – Workplace Solutions

DIE WIRKLICHE WELT

§ Die vollständige Domäne ist zu groß für ein einzelnes Modellè Bewusste Aufspaltung in Teilmodelle

§ Separate Modelle§ können unabhängig entwickelt werden§ Müssen den an sie gestellten

Anforderungen genügen

§ sollten klar abgegrenzt sein

è Jedes Modell sollte klein genug sein, so dass man es einem Team zuweisen kann

Page 91: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 91WPS – Workplace Solutions

KONTEXTGRENZEN (BOUNDED CONTEXT)

§ Jedes Modell hat einen Kontext§ Kontext = Grundsätzliche Voraussetzungen, damit Begriffe eine bestimmte Bedeutung erhalten§ Wird ein Modell aufgespalten, so ist für jedes Teilmodell eine Kontextdefinition erforderlich

§ Setze explizite Grenzen in der…§ Organisation von Teams§ Benutzung von Teilen der

Applikation§ Codebasis§ Entwicklung von

Datenbank-Schemas

Page 92: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 92WPS – Workplace Solutions

LIVING IN A BOX

§ Erhalte die Konsistenz innerhalb der Grenzen§ Keine Ablenkung durch äußere Angelegenheiten

§ Freie Gestaltung eines Teilmodells durch das zugehörige Team§ Kenne die Restriktionen§ Bleibe innerhalb der Modellgrenzen

§ Häufig werden Wertobjekte für die Kontext-Interkommunikation verwendet

Page 93: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 93WPS – Workplace Solutions

JEDER BOUNDED CONTEXT HAT SEIN EIGENES MODELL

Page 94: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 94WPS – Workplace Solutions

JEDER BOUNDED CONTEXT KANN EIN EIGENES TEAM HABEN

§ Entwicklung findet parallel statt§ Jedes Team korrespondiert mit einem Teil des Modells

§ à Microservices

Page 95: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 95WPS – Workplace Solutions

BOUNDED CONTEXTE SCHNEIDEN

Teilen Sie die Begriffe, die Sie für das Kino identifiziert haben, in zwei Bounded Contextsauf.

Page 96: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 96WPS – Workplace Solutions

BOUNDED CONTEXTS FÜR DAS KINO

Saalplan

Vorstellung

Reservierungs-nummer

Kinokarte

SaalplanstapelListe der Reservierungs-nummern

Gesamtablauf-plan

Tagesablaufplan

Film Platz/Sitzplatz

Saal/Kinosaal

WerbungVeranstaltung

EisverkaufVorführung

Kartenverkauf Ablaufplanung

Page 97: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 97WPS – Workplace Solutions

§ Subdomänen§ Kern (Core Domain)§ Unterstützende (Supporting Domain)§ Allgemeine (Generic Domain)

§ Context Mapping§ Shared Kernel§ Customer/Supplier§ Open-Host-Service§ Published Language§ Separate Ways§ Anticorruption Layer§ Conformist

STRATEGISCHES DESIGN – WEITERE BEGRIFFE

Page 98: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 98WPS – Workplace Solutions

DER PREIS FÜR DOMÄNENMODELLE

§ Zusätzliche Arbeit§ Definition der Modellgrenzen§ Definition der Beziehungen zwischen verschiedenen Modellen (Context Mapping)

§ Abbildungen zwischen verschiedenen Modellen§ Objekte können nicht zwischen den BC transportiert werden

Page 99: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 99WPS – Workplace Solutions

REDUKTION AUF BOUNDED CONTEXT »KARTENVERKAUF«

Saalplan

Vorstellung

Reservierungs-nummer

Kinokarte

SaalplanstapelListe der Reservierungs-nummern

Gesamtablauf-plan

Tagesablaufplan

Film Platz/Sitzplatz

Saal/Kinosaal

WerbungVeranstaltung

EisverkaufVorführung

Kartenverkauf Ablaufplanung

Page 100: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 100WPS – Workplace Solutions

REDUKTION AUF BOUNDED CONTEXT »KARTENVERKAUF«

Saalplan

Vorstellung

Reservierungs-nummer

Kinokarte

SaalplanstapelListe der Reservierungs-nummern

Film Platz/Sitzplatz

Saal/Kinosaal

Page 101: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 101WPS – Workplace Solutions

REDUKTION AUF BOUNDED CONTEXT »KARTENVERKAUF«

Saalplan

Vorstellung

Reservierungs-nummer

Kinokarte

SaalplanstapelListe der Reservierungs-nummern

Film Platz/Sitzplatz

Saal/Kinosaal

Page 102: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 102WPS – Workplace Solutions

REDUKTION AUF BOUNDED CONTEXT »KARTENVERKAUF«

Saalplan

Vorstellung

Reservierungs-nummer

Kinokarte

SaalplanstapelListe der Reservierungs-nummern

Film

Platz/Sitzplatz

Saal/Kinosaal

Page 103: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

WPS – Workplace Solutions #dddkonkret www.wps.de

FACHLICHE HANDLUNGENDomain-Driven Design hands-on

Page 104: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 104WPS – Workplace Solutions

§ Durch die Fachexperten (domain experts)

§ Sie wissen§ Worum es bei ihrer Arbeit geht§ Wo die Software sie unterstützen kann

èWer die Fachlichkeit nichtversteht, kann ihr nicht helfen

èSoftwareentwickler undFachexperten bilden zusammendas Team

WIE LERNEN WIR DIE FACHLICHKEIT?

Page 105: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 105WPS – Workplace Solutions

WIE KOMMEN WIR AN DAS WISSEN DER FACHEXPERTEN?

Techniken:§ Interviews§ Szenarios§ Event Storming§ Domain Storytelling

Das wollen wir extrahieren!

Fach-

wissen

Page 106: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 106WPS – Workplace Solutions

WORKSHOPS MIT ANWENDERN UND PRODUCT OWNERS

“Georgia?” by The Library of Congress, flickr.com

• Teilnehmer aus verschiedenen Bereichen (Business, IT, Management, …)• ein Moderator für den Workshop

à direktes Feedback von allen Beteiligten

Page 107: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 107WPS – Workplace Solutions

EVENT STORMING

§ Eine Methode um Geschäftsprozesse zu modellieren

§ Modelliert werden:§ Domain Events§ Commands§ Akteure§ Aggregates

Page 108: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 108WPS – Workplace Solutions

DOMAIN STORYTELLING

http://www.domainstorytelling.org

Modelliert werden:èAkteureèGegenständeèHandlungen

Page 109: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 109WPS – Workplace Solutions

FACHLICHE HANDLUNGEN IM IST IDENTIFIZIEREN

Handlungen an den Kernbegriffen identifizierenund auf den jeweiligen Sticker unter den Begriff schreiben.

Page 110: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 110WPS – Workplace Solutions

FACHLICHE HANDLUNGEN IM KARTENVERKAUF

Saalplan• Anzahl Plätze suchen• Verkaufte Plätze mark.• Reserv. Plätze mit RN

markieren

Vorstellung

Reservierungs-nummer

Kinokarte• Mit Platz beschriften

Saalplanstapel• Saalplan zu Vorst. Holen• Saalplan zurücklegen

Liste der Reservierungsnummern• Reservierungsnummer abholen• Name+Vorst. Vermerken• Vorst. Mit RN heraussuchen

Film

Platz/Sitzplatz

Saal/Kinosaal

Page 111: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 111WPS – Workplace Solutions

EINIGE DATEN ERGÄNZEN

Vorstellung• Datum• Zeitraum• Film

Kinokarte• Mit Platz beschriften• Vorstellung

Film• Titel• Regisseur, Schauspieler• Freigabe• Spieldauer

Platz/Sitzplatz• Reihe• Nummer

Saal/Kinosaal• Kapazität• Anzahl Reihen

Saalplan• Anzahl Plätze suchen• Verkaufte Plätze mark.• Reserv. Plätze mit RN

markieren

Reservierungs-nummer

Saalplanstapel• Saalplan zu Vorst. Holen• Saalplan zurücklegen

Liste der Reservierungsnummern• Reservierungsnummer abholen• Name+Vorst. Vermerken• Vorst. Mit RN heraussuchen

Page 112: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

WPS – Workplace Solutions #dddkonkret www.wps.de

TAKTISCHES DESIGNDomain-Driven Design konkret

Page 113: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 113WPS – Workplace Solutions

DOMAIN-DRIVEN DESIGN – SCHICHTENARCHITEKTUR

§ User-Interface-Schicht

§ Nimmt Eingaben und Benutzerkommandos entgegen und stelltInformationen dar.

§ Application-Schicht

§ Beschreibt und koordiniert Geschäftsprozesse. § Kann in vielen Anwendungen entfallen, weil die Domain-Schicht

ihre Aufgabe wahrnimmt.

§ Domain-Schicht

§ Repräsentiert die Fachdomäne.

§ Infrastruktur-Schicht

§ Bietet technische Dienste, wie beispielsweise Persistenz oder die Kommunikation mit anderen Systemen.

User Interface

Domain

Infrastructure

Application

Page 114: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 114WPS – Workplace Solutions

Domain

ELEMENTE DER DOMAIN-SCHICHT

User Interface

Infrastructure

Application

DomainService

Factory

Value Object

Repository

Root Entity

Entity Entity

ApplicationService

Aggregate

Page 115: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 115WPS – Workplace Solutions

ENTITIES

§ Sind die Kernobjekte einer Fachdomäne.§ Besitzen eine zustandsunabhängige,

unveränderliche Identität.§ Haben einen klar definierten Lebenszyklus.§ Besitzen einen (meist veränderlichen) Zustand.§ Beschreiben ihren Zustand mithilfe von

Value Objects.§ Sind praktisch immer persistent.

§ Auch: Business Objects / Domain Objects

à NICHT ZU VERWECHSELN mit dem Begriff "ENTITY" aus dem Entity-Relationship-Modell!

Page 116: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 116WPS – Workplace Solutions

ENTITIES – BEISPIELE

Versicherungspolice

UrlaubsantragBaumaßnahme

Kaufvertrag

Fahrauftrag

Page 117: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 117WPS – Workplace Solutions

VALUE OBJECTS

§ Symbolisieren Werte eines bestimmten Typs der Fachdomäne.

§ Symbolisieren bei Gleichheit denselben Wert.§ Sind unveränderlich.§ Können ggf. (aus anderen Value Objects)

berechnet werden.§ Können aus anderen Value Objects bestehen,

aber nie aus Entitäten!

ValueObject

2,5ValueObject

ValueObject

ValueObject

ValueObject

zwei-einhalb

Page 118: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 118WPS – Workplace Solutions

VALUE OBJECTS – BEISPIELE

Postleitzahl

GPS-Koordinate

IBAN

Containernummer

IATA-Code

Page 119: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 119WPS – Workplace Solutions

ENTITES, VALUE OBJECTS

Welche Entities haben wir modelliert? Welche Value Objects gibt es? Welche IST-Konzepte sind für das SOLL überflüssig?

Page 120: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 120WPS – Workplace Solutions

ENTITIES UND VALUE OBJECTS IM KARTENVERKAUF

Saalplan• Anzahl Plätze suchen• Verkaufte Plätze mark.• Reserv. Plätze mit RN

markieren

Vorstellung• Datum• Zeitraum• Film

Reservierungs-nummer

Kinokarte• Mit Platz beschriften• Vorstellung

Saalplanstapel• Saalplan zu Vorst. Holen• Saalplan zurücklegen

Liste der Reservierungsnummern• Reservierungsnummer abholen• Name+Vorst. Vermerken• Vorst. Mit RN heraussuchen

Film• Titel• Regisseur, Schauspieler• Freigabe• Spieldauer

Platz/Sitzplatz• Reihe• Nummer

Saal/Kinosaal• Kapazität• Anzahl Reihen

VO

Entity

Entity

Entity

Entity Entity

Entity

Page 121: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 121WPS – Workplace Solutions

ENTITIES UND VALUE OBJECTS IM KARTENVERKAUF

Saalplan• Anzahl Plätze suchen• Verkaufte Plätze mark.• Reserv. Plätze mit RN

markieren

Vorstellung• Datum• Zeitraum• Film

Reservierungs-nummer

Liste der Reservierungsnummern• Reservierungsnummer abholen• Name+Vorst. Vermerken• Vorst. Mit RN heraussuchen

Film• Titel• Regisseur, Schauspieler• Freigabe• Spieldauer

Platz/Sitzplatz• Reihe• Nummer

Saal/Kinosaal• Kapazität• Anzahl Reihen

VO

Entity

Entity

Entity

Entity Entity

Entity

Page 122: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

WPS – Workplace Solutions #dddkonkret www.wps.de

AGGREGATES

Page 123: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 123WPS – Workplace Solutions

AGGREGATE

§ Bildet eine Klammer um eine Struktur von Entities.

§ Besitzt grundsätzlich eine ausgezeichnete Entität als Einstiegspunkt (Wurzel).

§ Wird fachlich als eine zusammenhängende Einheit betrachtet.

§ Schützt Konsistenz und Integrität ihrer innerer Entities (muss sie dazu aber nicht notwendigerweise verbergen!), sowie die eigene Konsistenz und Integrität!

§ Technik:§ Wird üblicherweise in der Datenbank

gespeichert.§ Als Ganzes!

Wurzel-Entity

Entity

Entity

EntityEntity

VO

VO VO

VO

VO VO VO VO

VO

VO

VO

VO

Aggregate

Page 124: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 124WPS – Workplace Solutions

AGGREGATE

§ Besteht oft auch nur aus einer Entity

§ Oft gleicher Name wie die Wurzel-EntityWurzel-Entity

VO

VO

VO

Aggregate

Page 125: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 125WPS – Workplace Solutions

ENTITIES UND VALUE OBJECTS IM KARTENVERKAUF

Saalplan• Anzahl Plätze suchen• Verkaufte Plätze mark.• Reserv. Plätze mit RN

markieren

Vorstellung• Datum• Zeitraum• Film

Reservierungs-nummer

Liste der Reservierungsnummern• Reservierungsnummer abholen• Name+Vorst. Vermerken• Vorst. Mit RN heraussuchen

Film• Titel• Regisseur, Schauspieler• Freigabe• Spieldauer

Platz/Sitzplatz• Reihe• Nummer

Saal/Kinosaal• Kapazität• Anzahl Reihen

VO

Entity

Entity

Entity

Entity Entity

Entity

Page 126: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 126WPS – Workplace Solutions

AGGREGATES SCHNEIDEN

Aggregate-Grenzen um Entites und Value Objects ziehen.

Page 127: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 127WPS – Workplace Solutions

ENTITIES UND VALUE OBJECTS IM KARTENVERKAUF

Saalplan• Anzahl Plätze suchen• Verkaufte Plätze mark.• Reserv. Plätze mit RN

markieren

Vorstellung• Datum• Zeitraum• Film

Reservierungs-nummer

Liste der Reservierungsnummern• Reservierungsnummer abholen• Name+Vorst. Vermerken• Vorst. Mit RN heraussuchen

Film• Titel• Regisseur, Schauspieler• Freigabe• Spieldauer

Platz/Sitzplatz• Reihe• Nummer

Saal/Kinosaal• Kapazität• Anzahl Reihen

VO

Entity

Entity

Wurzel-Entity

Entity Entity

Entity

Aggregate

Aggregate

Aggregate Aggregate

Aggregate

Page 128: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

WPS – Workplace Solutions #dddkonkret www.wps.de

MEHR BAUSTEINE

Page 129: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 129WPS – Workplace Solutions

Service

SERVICES

§ Stellen Abläufe oder Prozesse der Fachdomäne dar, die nicht von Entitäten ausgeführt werden können.

§ Sind zustandslos!§ Parameter und Ergebnisse ihrer Operationen sind

Entities und Value Objects.

§ Auch: Fachlicher Service

§ NICHT ZU VERWECHSELN mit den "technischen Services" der Application-Schicht!

Page 130: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 130WPS – Workplace Solutions

FACTORIES

§ Erzeugen Aggregate, Entities (und ggf. auch Value Objects).

§ Arbeiten ausschließlich innerhalb der Domain-Schicht.

Factory

Page 131: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 131WPS – Workplace Solutions

REPOSITORIES

§ Kapseln die technischen Details der technischen Infrastrukturschicht…

§ … und bilden deren Daten auf fachliche Entitiesund Value Objects ab.

§ Persistieren Entities z.B. in Datenbanken.Repository

Page 132: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 132WPS – Workplace Solutions

DIE »KERNELEMENTE«

Services

Value Objects

Entities/Aggregates

zustandslos

veränderlicher Zustand

unveränderlicher Zustand

"Mik

ro-S

chic

htun

g" (n

icht

str

ikt!

)

Page 133: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 133WPS – Workplace Solutions

ELEMENTE DER DOMAIN-SCHICHT

Services

Factories

Value Objects

Repositories Infrastruktur-Komponente

"Mik

ro-S

chic

htun

g" (n

icht

str

ikt!

)

Fachobjekte

Unterstützen den Lebenszyklus der Fachobjekte

Entities/Aggregate

Page 134: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 134WPS – Workplace Solutions

Domain Event

DOMAIN EVENTS

§ Signalisieren Ereignisse, die aus fachlicher Sicht relevant sind

§ Signalisieren Ereignisse die geschehen sind (NICHT solche, die passieren sollen).

§ Werden zur Kommunikation zwischen BoundedContexts verwendet und…§ … fördern so deren Entkoppelung,§ … erleichtern asynchrone Prozesse.

§ Bewirken Reaktionen der Subsysteme, die sich für diese fachlichen Ereignisse interessieren.

Page 135: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 135WPS – Workplace Solutions

DOMAIN EVENTS – BEISPIELE

RechnungAusgestellt

ÜberweisungErfolgt

BuchVerkauft KontoEröffnet

Page 136: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 136WPS – Workplace Solutions

TRENNUNG VON FACHLICHER + TECHNISCHER SOFTWARE

Application Kernel

Persistence

GUI 2

Database

Altsystem B

Altsystem AAdapterA

AdapterB

GUI 1

interfaces submittedtothird parties

Transformations-Software

Technische Software

Vermischte Software

Fachliche Software

Page 137: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 137WPS – Workplace Solutions

Domain

ELEMENTE DER DOMAIN-SCHICHT

User Interface

Infrastructure

Application

Domain Service

Factory

Value Object

Repository

Root Entity

Entity Entity

ApplicationService

Aggregate

Page 138: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 138WPS – Workplace Solutions

Domain

User Interface

Infrastructure

Application

Domain Service

Factory

Value Object

Repository

Root Entity

Entity Entity

ApplicationService

Aggregate

ELEMENTE DER DOMAIN-SCHICHTNicht erlaubte Beziehungen (typische Beispiele)

Page 139: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 139WPS – Workplace Solutions

SERVICES, REPOSITORIES, FACTORIES

Welche Services könnten wir brauchen? Welche Repositories oder Factories benötigt unser System?

Page 140: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

WPS – Workplace Solutions #dddkonkret www.wps.de

DIE BAUSTEINE IMPLEMENTIERENDomain-Driven Design konkret

Page 141: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 141WPS – Workplace Solutions

EIN BANKKONTO – ERSTER ENTWURF

public class Account {private int _balance;

public int getBalance() {return _balance;

}

public void setBalance(int balance) {_balance = balance;

}}

Page 142: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 142WPS – Workplace Solutions

EIN BANKKONTO – ERSTER ENTWURF

public class Account {private int _balance;

public int getBalance() {return _balance;

}

public void setBalance(int balance) {_balance = balance;

}}

�Schlecht: Der

Kontostand kannauf beliebigenWert gesetzt

werden

Page 143: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 143WPS – Workplace Solutions

EIN BANKKONTO – ZWEITER ENTWURF

public class Account {private int _balance;

public int getBalance() {return _balance;

}

public void deposit(int amount) {_balance += amount;

}

public void withdraw(int amount) {_balance -= amount;

}}

Besser: Methoden mit

fachlichemVerhalten und

Namen

Page 144: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 144WPS – Workplace Solutions

EIN BANKKONTO – DRITTER ENTWURF

public class Account {private int _balance;

public int getBalance() {return _balance;

}

public void deposit(int amount) {_balance += amount;

}

public void withdraw(int amount) {if (amount >= getBalance()) {

throw new IllegalArgumentException("Amount too big");}_balance -= amount;

}}

Noch besser: Vorbedingungenkönnen geprüft

werden

Page 145: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 145WPS – Workplace Solutions

ÜBERSICHT

§ Entities Implementieren§ Beispiel-Entity§ Vertragsmodell (Design by contract)§ Beispiel-Value-Object§ Identität von Entities

Page 146: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 146WPS – Workplace Solutions

EIN BANKKONTO – VERTRAGSMODELL MIT ASSERT

public class Account {

// ...

public void withdraw(int amount) {assert amount >= getBalance();_balance -= amount;

}}

Prüfung mitSchlüsselwort

assert

Page 147: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 147WPS – Workplace Solutions

EIN BANKKONTO – VERTRAGSMODELL MIT VALID4J

import static org.valid4j.Assertive.*;

public class Account {

// ...

public void withdraw(int amount) {require(amount <= getBalance());_balance -= amount;

}}

HamcrestMatchers können

verwendetwerden

Page 148: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 148WPS – Workplace Solutions

EIN BANKKONTO – VERTRAGSMODELL MIT CODE CONTRACTS

using System.Diagnostics.Contracts;

public class Account {

// ...

public void Withdraw(int amount) {Contract.Requires(amount <= Balance);_balance -= amount;

}}

Page 149: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 149WPS – Workplace Solutions

JA, ABER…

public class Account {

// ...

public void withdraw(int amount) {assert amount >= getBalance();_balance -= amount;

}}

Kann ich einenNegativen

Betragabheben?

In EUR oderGBP oder … ?

Page 150: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 150WPS – Workplace Solutions

ÜBERSICHT

§ Entities Implementieren§ Beispiel-Entity§ Vertragsmodell (Design by contract)§ Beispiel-Value-Object§ Identität von Entities

Page 151: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 151WPS – Workplace Solutions

EIN EIGENER BETRAGS-TYP

public class Amount {private final int _amount;private final Currency _currency;

public Amount(int amount, Currency currency) {_amount = amount;_currency = currency;

}}

Page 152: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 152WPS – Workplace Solutions

EIN EIGENER BETRAGS-TYP

public class Amount {private final int _amount;private final Currency _currency;

public Amount(int amount, Currency currency) {_amount = amount;_currency = currency;

}

public Amount add(Amount otherAmount) {return new Amount(_amount + otherAmount._amount, _currency);

}}

Der neue Typ hat richtiges

fachlichesVerhalten

Page 153: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 153WPS – Workplace Solutions

EIN EIGENER BETRAGS-TYP

public class Amount {private final int _amount;private final Currency _currency;

public Amount(int amount, Currency currency) {_amount = amount;_currency = currency;

}

public Amount add(Amount otherAmount) {assert hasSameCurrency(otherAmount);

return new Amount(_amount + otherAmount._amount, _currency);}

public boolean hasSameCurrency(Amount otherAmount) {return otherAmount._currency == _currency;

}}

… und Verträge, die vor falschen

Währungen schützen

Page 154: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 154WPS – Workplace Solutions

EIN BANKKONTO – VIERTER ENTWURF

public class Account {private Amount _balance;

public Amount getBalance() {return _balance;

}

public void deposit(Amount amount) {_balance.add(amount);

}

public void withdraw(Amount amount) {assert amount.isLessOrEqual(getBalance());_balance.subtract(amount);

}}

Jetzt können wirden Betrags-Typ

verwenden

Page 155: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 155WPS – Workplace Solutions

EIN BANKKONTO – VIERTER ENTWURF

public class Account {private Amount _balance;

public Amount getBalance() {return _balance;

}

public void deposit(Amount amount) {_balance = _balance.add(amount);

}

public void withdraw(Amount amount) {assert amount.hasSameCurrency(getBalance());assert amount.isLessOrEqual(getBalance());_balance = _balance.subtract(amount);

}}

… und neue Verträge

formulieren

Page 156: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 156WPS – Workplace Solutions

ÜBERSICHT

§ Entities Implementieren§ Beispiel-Entity§ Vertragsmodell (Design by contract)§ Beispiel-Value-Object§ Identität von Entities

Page 157: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 157WPS – Workplace Solutions

IDENTITÄT VON ENTITIES

§ In Java hat jedes Objekt eine Identität§ Nämlich seine Referenz

§ Das ist eine technische Identität

§ Eine Entität hat eine fachliche Identität§ Verschiedene Objekte können dieselbe Entität repräsentieren§ In verschiedenen Prozessen: z.B. auf dem Client/auf dem Server§ Wenn sie gespeichert und später wieder aus der Datenbank gelesen werden.

§ Die fachliche Identität kann dem Benutzer bekannt sein auf zwei Arten:§ Explizit (z.B. IBAN)§ Implizit (z.B. GUID)

?

Page 158: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 158WPS – Workplace Solutions

EIN BANKKONTO – MIT FACHLICHER IDENTITÄT

public class Account {

// ...

private final IBAN _iban;

public Account(IBAN iban) {_iban = iban;

}

@Overridepublic boolean equals(Object other) {

return _iban.equals(((Account)other)._iban);}

}

Die Identität ist unveränderlich

Der Typ der Identität ist

typischerweise ein Value Object

Die Implementation von equals() basiert

auf der Identität

Page 159: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 159WPS – Workplace Solutions

WER ERZEUGT EINE NEUE IDENTITÄT?

§ Die Datenbank§ Pro: Zentral§ Kann manchmal »lazy« erzeugt werden

§ Eine systemweite Fabrik§ Für dem Benutzer bekannte Formate§ Oft in dem Repository, das zum passenden Entity-Typ gehört

§ Ein GUID-Generator§ Pro: kann auf dem Client ohne Verbindung zum Server erzeugt werden§ Con: String in einem besonderen Format

Page 160: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 160WPS – Workplace Solutions

ÜBUNG: MOBPROGRAMMING

Page 161: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 161WPS – Workplace Solutions

WAS WIR NICHT BAUEN WOLLEN

ANEMIC DOMAIN MODEL

Page 162: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 162WPS – Workplace Solutions

ANEMIC DOMAIN MODEL

§ „blutarme“ fachliche Objekte § Schnittstelle ohne Aussagekraft

§ aus Gettern/Settern § Viele String Parameter

§ Eigentliche Fachlichkeit außerhalb Entities + Value Objects in Services oder im UI

§ Oberhalb des Modells findet man Klassen mit dupliziertem Code zur

§ Konsistenzprüfung§ Konvertierung§ Validierung

§ Viele Util, Helper und Manager Klassen

Page 163: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 163WPS – Workplace Solutions

ANEMIC à FEHLENDE ROBUSTHEIT

§ Designschulden§ Unklarer, schwer verständlicher Entwurf§ Verteilte Fachlichkeit§ Copy&Paste-Programmierung

à Teure Wartungà Duplizierter Codeà Viele Refactoringsà Schlechte Testbarkeit

Page 164: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE
Page 165: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

@hschwentner

Literatur

Page 166: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

@hschwentner

speakerdeck.com/hschwentner

Page 167: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE
Page 168: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE
Page 169: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE
Page 170: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 170WPS – Workplace Solutions

MEETUPS

@DDDger

Page 171: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

24.05.17 //// Seite 171WPS – Workplace Solutions

KONFERENZEN

Germanys first DDD conference

Page 172: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

WorkshopDomain-Driven Designkonkret

wps.de/ddd

Page 173: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

§Foto: Henning Schwentner

Page 174: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

@hschwentner

Rabatt!

Page 175: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

@hschwentner

FEEDBACK

Page 176: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

@hschwentner

Page 177: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE
Page 178: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE
Page 179: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE
Page 180: DDD hands on - Entwicklertag · 2017-05-27 · Inheritance O/R-Mapping A B Method Interface Linux Windows Eclipse Visual Studio. WPS –WorkplaceSolutions 24.05.17////Seite 64 DOMÄNEN-SPRACHE

Henning Schwentner

[email protected]@hschwentner

�!