Slide 1

Slide 1 text

Starring Directed By Presented by With

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

https://hschwentner.io

Slide 5

Slide 5 text

@hschwentner

Slide 6

Slide 6 text

! " # $

Slide 7

Slide 7 text

@hschwentner

Slide 8

Slide 8 text

BankAccount withdraw() deposit() Amount

Slide 9

Slide 9 text

BankAccount withdraw() deposit() Amount

Slide 10

Slide 10 text

@hschwentner Domain-Driven Design Eric Evans

Slide 11

Slide 11 text

@hschwentner Entity vs. Value - Identity - Life cycle - Can be mutable - No identity - Always immutable Contract Map Name Length 12.5 m “John Miller”

Slide 12

Slide 12 text

Entity Value Object Aggregate Service Factory Repository Tactical Design

Slide 13

Slide 13 text

«Entity» BankAccount withdraw() deposit() «Value Object» Amount

Slide 14

Slide 14 text

«stereotype» Value Object «stereotype» Entity ??? «stereotype» Identity

Slide 15

Slide 15 text

xMolecules

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

Hexagonal Architecture Layerered Architecture Onion Architecture Clean Architecture

Slide 18

Slide 18 text

@hschwentner How To Express Architecture?

Slide 19

Slide 19 text

class Account { public void deposit(Amount amount) //... public void withdraw(Amount amount) //... }

Slide 20

Slide 20 text

class AccountEntity { public void deposit(Amount amount) //... public void withdraw(Amount amount) //... }

Slide 21

Slide 21 text

class Account extends Entity { public void deposit(Amount amount) //... public void withdraw(Amount amount) //... }

Slide 22

Slide 22 text

class Account extends Entity { public void deposit(Amount amount) //... public void withdraw(Amount amount) //... }

Slide 23

Slide 23 text

import org.jmolecules.ddd.types.Entity; class Account extends Entity { public void deposit(Amount amount) //... public void withdraw(Amount amount) //... }

Slide 24

Slide 24 text

@Entity class Account { public void deposit(Amount amount) //... public void withdraw(Amount amount) //... }

Slide 25

Slide 25 text

import org.jmolecules.ddd.annotation.Entity; @Entity class Account { public void deposit(Amount amount) //... public void withdraw(Amount amount) //... }

Slide 26

Slide 26 text

@hschwentner How To Express Architecture?

Slide 27

Slide 27 text

class Account { public void deposit(Amount amount) //... public void withdraw(Amount amount) //... }

Slide 28

Slide 28 text

class AccountEntity { public void deposit(Amount amount) //... public void withdraw(Amount amount) //... }

Slide 29

Slide 29 text

class Account : Entity { public void deposit(Amount amount) //... public void withdraw(Amount amount) //... }

Slide 30

Slide 30 text

class Account : Entity { public void deposit(Amount amount) //... public void withdraw(Amount amount) //... }

Slide 31

Slide 31 text

using NMolecules.DDD; class Account : Entity { public void deposit(Amount amount) //... public void withdraw(Amount amount) //... }

Slide 32

Slide 32 text

[Entity] class Account { public void deposit(Amount amount) //... public void withdraw(Amount amount) //... }

Slide 33

Slide 33 text

using NMolecules.DDD; [Entity] class Account { public void deposit(Amount amount) //... public void withdraw(Amount amount) //... }

Slide 34

Slide 34 text

[Entity] class Account { [Identity] public IBAN IBAN { get; } public void deposit(Amount amount) //... public void withdraw(Amount amount) //... }

Slide 35

Slide 35 text

@hschwentner How To Express Architecture?

Slide 36

Slide 36 text

class Account { public function deposit(Amount $amount) //... public function withdraw(Amount $amount) //... }

Slide 37

Slide 37 text

class AccountEntity { public function deposit(Amount $amount) //... public function withdraw(Amount $amount) //... }

Slide 38

Slide 38 text

class Account extends Entity { public function deposit(Amount $amount) //... public function withdraw(Amount $amount) //... }

Slide 39

Slide 39 text

/** * @extends Entity */ class Account extends Entity { public function deposit(Amount $amount) //... public function withdraw(Amount $amount) //... }

Slide 40

Slide 40 text

use PHPMolecules\DDD\Type\Entity; class Account extends Entity { public function deposit(Amount $amount) //... public function withdraw(Amount $amount) //... }

Slide 41

Slide 41 text

#[Entity] class Account { public function deposit(Amount $amount) //... public function withdraw(Amount $amount) //... }

Slide 42

Slide 42 text

use PHPMolecules\DDD\Annotation\Entity; #[Entity] class Account { public function deposit(Amount $amount) //... public function withdraw(Amount $amount) //... }

Slide 43

Slide 43 text

@hschwentner Why Express Architecture?

Slide 44

Slide 44 text

Documentation Verification Boilerplate Reduction

Slide 45

Slide 45 text

@hschwentner Documentation

Slide 46

Slide 46 text

@hschwentner ! " «Entity» XXX «Value Object» YYY ??

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

@hschwentner Verification

Slide 49

Slide 49 text

@hschwentner value Architecture Rules entity allowed forbidden

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

@AnalyzeClasses(packagesOf = ArchitectureTests.class) class ArchitectureTests { @ArchTest ArchRule ddd = JMoleculesDddRules.all(); }

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

PHPStan Psalm Phan PHPArkitect PHPArch

Slide 54

Slide 54 text

@hschwentner Boilerplate Reduction

Slide 55

Slide 55 text

@javax.persistence.Entity class BankAccount { /*...*/ } @javax.persistence.???.Embeddable class Amount { /*...*/ }

Slide 56

Slide 56 text

@hschwentner jmolecules-bytebuddy jmolecules-jpa jmolecules-spring jmolecules-jackson jmolecules-intellij

Slide 57

Slide 57 text

@hschwentner Boilerplate Reduction

Slide 58

Slide 58 text

???

Slide 59

Slide 59 text

@hschwentner nmolecules-ef nmolecules-roslyn nmolecules-rider

Slide 60

Slide 60 text

@hschwentner Boilerplate Reduction

Slide 61

Slide 61 text

/** * @ORM\Entity * @ORM\Table(name="bank_accounts") */ class BankAccount { /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private IBAN iban; /*...*/ }

Slide 62

Slide 62 text

@hschwentner phpmolecules-doctrine phpmolecules-symphony phpmolecules-serializer phpmolecules-phpstorm

Slide 63

Slide 63 text

@hschwentner Installation

Slide 64

Slide 64 text

org.jmolecules jmolecules-ddd 1.4.0

Slide 65

Slide 65 text

@hschwentner Installation

Slide 66

Slide 66 text

> dotnet add package NMolecules.DDD

Slide 67

Slide 67 text

// Install NMolecules.DDD as a Cake Addin #addin nuget:?package=NMolecules.DDD&version=0.2.1 // Install NMolecules.DDD as a Cake Tool #tool nuget:?package=NMolecules.DDD&version=0.2.1

Slide 68

Slide 68 text

@hschwentner Installation

Slide 69

Slide 69 text

$ composer require --dev xmolecules/phpmolecules

Slide 70

Slide 70 text

@hschwentner LeasingNinja.io

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

Bibliography Evans, Eric. Domain-Driven Design: Tackling Complexity in the Heart of Software. Boston: Addison-Wesley, 2004. Hofer, Stefan and Henning Schwentner. Domain Storytelling: a Collaborative, Visual, and Agile Way to Develop Domain-Driven Software. Boston: Addison-Wesley, 2022.

Slide 73

Slide 73 text

No content

Slide 74

Slide 74 text

Henning Schwentner ⌂ https://hschwentner.io @hschwentner [email protected]