DDD Antipatterns

DDD Antipatterns

I have written a lot of codes with Domain-Driven Design(DDD) on production and experienced both success and failure of DDD.

So this is how to prevent DDD failure.

79c4628dcfbaec6f780461cf51091bc4?s=128

resotto

June 07, 2020
Tweet

Transcript

  1. DDD Antipatterns Avoiding Costly Mistakes of DDD Programming

  2. 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
  3. Index - Old Schema - [WIP] Thick Application Service -

    [WIP] Non-Operating Factory - [WIP] Insufficient Refactoring - [WIP] Pending Absorption of Domain Knowledge
  4. Old Schema

  5. 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
  6. Antipattern Using the old table schema as it is As

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

    Is To Be
  8. 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
  9. Why? Because Domain Model depends on the old table schema

    by reversing the direction of dependency. Robert C. Martin Clean Architecture
  10. Robert C. Martin Clean Architecture

  11. Robert C. Martin Clean Architecture

  12. Robert C. Martin Clean Architecture

  13. 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
  14. 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
  15. 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
  16. When to be acceptable? When properties of the Domain Model

    correspond to columns of remaining tables consequently Domain Model
  17. 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
  18. 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
  19. 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
  20. 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
  21. 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
  22. Domain Model

  23. 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
  24. 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
  25. 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
  26. 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
  27. 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
  28. Solution Making up new table schema As Is To Be

  29. Solution Making up new table schema As Is To Be

  30. 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!
  31. Thank you!