Upgrade to Pro — share decks privately, control downloads, hide ads and more …

DDD Antipatterns

resotto
June 07, 2020

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.

resotto

June 07, 2020
Tweet

Other Decks in Programming

Transcript

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

    [WIP] Non-Operating Factory - [WIP] Insufficient Refactoring - [WIP] Pending Absorption of Domain Knowledge
  3. 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
  4. 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
  5. Why? Because Domain Model depends on the old table schema

    by reversing the direction of dependency. Robert C. Martin Clean Architecture
  6. 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
  7. 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
  8. 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
  9. When to be acceptable? When properties of the Domain Model

    correspond to columns of remaining tables consequently Domain Model
  10. 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
  11. 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
  12. 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
  13. 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
  14. 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
  15. 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
  16. 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
  17. 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
  18. 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
  19. 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
  20. 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!