Slide 1

Slide 1 text

DDD Antipatterns Avoiding Costly Mistakes of DDD Programming

Slide 2

Slide 2 text

About me - Software Engineer - I like Sushi. https://github.com/resotto https://twitter.com/resotto3 © 2016 Side Project. CC BY 3.0 https://www.iconfinder.com/iconsets/colorful-guache-social-media-logos-1

Slide 3

Slide 3 text

Index - Old Schema - [WIP] Thick Application Service - [WIP] Non-Operating Factory - [WIP] Insufficient Refactoring - [WIP] Pending Absorption of Domain Knowledge

Slide 4

Slide 4 text

Old Schema

Slide 5

Slide 5 text

Purpose Replacing an application with Domain-Driven Design © 2017 Iconika. CC BY 3.0 https://www.iconfinder.com/iconsets/arrows-107 https://www.iconfinder.com/iconsets/social-productivity-1

Slide 6

Slide 6 text

Antipattern Using the old table schema as it is As Is To Be

Slide 7

Slide 7 text

Antipattern Using the old table schema as it is As Is To Be

Slide 8

Slide 8 text

Antipattern Using the old table schema as it is As Is To Be © 2017 Iconika. CC BY 3.0 https://www.iconfinder.com/iconsets/social-productivity

Slide 9

Slide 9 text

Why? Because Domain Model depends on the old table schema by reversing the direction of dependency. Robert C. Martin Clean Architecture

Slide 10

Slide 10 text

Robert C. Martin Clean Architecture

Slide 11

Slide 11 text

Robert C. Martin Clean Architecture

Slide 12

Slide 12 text

Robert C. Martin Clean Architecture

Slide 13

Slide 13 text

How to find it? Following conversation would be taken place: (How) Can I use remaining tables with DDD? © 2017 Iconika. CC BY 3.0 https://www.iconfinder.com/iconsets/social-productivity

Slide 14

Slide 14 text

How to find it? Following conversation would be taken place: I feel writing DTOs is so hard. (How) Can I use remaining tables with DDD? © 2017 Iconika. CC BY 3.0 https://www.iconfinder.com/iconsets/social-productivity

Slide 15

Slide 15 text

How to find it? Following conversation would be taken place: I feel writing DTOs is so hard. (How) Can I use remaining tables with DDD? Domain Model properties can’t help but look like table columns. © 2017 Iconika. CC BY 3.0 https://www.iconfinder.com/iconsets/social-productivity

Slide 16

Slide 16 text

When to be acceptable? When properties of the Domain Model correspond to columns of remaining tables consequently Domain Model

Slide 17

Slide 17 text

When to be acceptable? When properties of the Domain Model correspond to columns of remaining tables consequently Domain Model © 2014 Hard Task. CC BY 3.0 https://www.iconfinder.com/iconsets/arrow-5

Slide 18

Slide 18 text

When to be acceptable? When properties of the Domain Model correspond to columns of remaining tables consequently Domain Model As Is © 2014 Hard Task. CC BY 3.0 https://www.iconfinder.com/iconsets/arrow-5

Slide 19

Slide 19 text

When to be acceptable? When properties of the Domain Model correspond to columns of remaining tables consequently Domain Model This Order! As Is © 2014 Hard Task. CC BY 3.0 https://www.iconfinder.com/iconsets/arrow-5

Slide 20

Slide 20 text

What if you have to use old schema? It might be impossible to replace an application with DDD. https://www.iconfinder.com/iconsets/social-productivity-1 © 2017 Iconika. CC BY 3.0 https://www.iconfinder.com/iconsets/arrows-107

Slide 21

Slide 21 text

What if you have to use old schema? It might be impossible to replace an application with DDD. © 2017 Iconika. CC BY 3.0 https://www.iconfinder.com/iconsets/arrows-107 https://www.iconfinder.com/iconsets/social-productivity-1

Slide 22

Slide 22 text

Domain Model

Slide 23

Slide 23 text

If Domain Model properties don’t correspond to the old table columns... Domain Model © 2014 Hard Task. CC BY 3.0 https://www.iconfinder.com/iconsets/arrow-5

Slide 24

Slide 24 text

As Is If Domain Model properties don’t correspond to the old table columns... Domain Model © 2014 Hard Task. CC BY 3.0 https://www.iconfinder.com/iconsets/arrow-5

Slide 25

Slide 25 text

As Is If Domain Model properties don’t correspond to the old table columns... Domain Model Oops! “weight” can’t be stored! © 2014 Hard Task. CC BY 3.0 https://www.iconfinder.com/iconsets/arrow-5

Slide 26

Slide 26 text

As Is If Domain Model properties don’t correspond to the old table columns... Domain Model And do I have to add “name” to Domain Model??? © 2014 Hard Task. CC BY 3.0 https://www.iconfinder.com/iconsets/arrow-5

Slide 27

Slide 27 text

As Is If Domain Model properties don’t correspond to the old table columns... Domain Model Oops! “weight” can’t be stored! And do I have to add “name” to Domain Model??? © 2014 Hard Task. CC BY 3.0 https://www.iconfinder.com/iconsets/arrow-5 © 2017 Iconika. CC BY 3.0 https://www.iconfinder.com/iconsets/social-productivity

Slide 28

Slide 28 text

Solution Making up new table schema As Is To Be

Slide 29

Slide 29 text

Solution Making up new table schema As Is To Be

Slide 30

Slide 30 text

Old Schema - Purpose: replacing an application with DDD - Antipattern: using the old table schema as it is - Why: because of reversing dependency - Solution: making up new table schema Wrap Up!

Slide 31

Slide 31 text

Thank you!