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

Practical Domain Driven Design With EFCore - NDC Sydney 2020

Practical Domain Driven Design With EFCore - NDC Sydney 2020

Hossam Barakat

October 14, 2020
Tweet

More Decks by Hossam Barakat

Other Decks in Programming

Transcript

  1. Practical Domain-Driven Design With EF Core Hossam Barakat Technical Lead

    at Willow @hossambarakat_ | www.hossambarakat.net
  2. @hossambarakat_ What is Domain-Driven Design? “Domain-Driven Design is an approach

    to software development that centers the development on programming a domain model that has a rich understanding of the processes and rules of a domain. ” -- Martin Fowler
  3. @hossambarakat_ What is Domain Model? “An object model of the

    domain that incorporates both behavior and data. ” - Martin Fowler “A system of abstractions that describes selected aspects of a domain and can be used to solve problems related to that domain. ” -- Eric Evans
  4. @hossambarakat_ Strategic Design

  5. @hossambarakat_ Bounded Contexts • A defined part of software where

    particular terms, definitions and rules apply in a consistent way • Clear boundaries between different parts of the system https://martinfowler.com/bliki/BoundedContext.html
  6. @hossambarakat_ Focus on the Core Domain

  7. @hossambarakat_ Inside the Core Domain

  8. @hossambarakat_ How to apply DDD to my legacy codebase?

  9. @hossambarakat_ Sample Domain

  10. @hossambarakat_ Sample Domain

  11. @hossambarakat_ Domain Model

  12. @hossambarakat_ Demo

  13. @hossambarakat_ Extract Methods

  14. @hossambarakat_ Avoid Public Setters

  15. @hossambarakat_ Encapsulate Behavior in Domain Model

  16. @hossambarakat_ Encapsulate Collection

  17. @hossambarakat_ Encapsulate Behavior in Domain Model

  18. @hossambarakat_ Encapsulate Behavior in Domain Service

  19. @hossambarakat_ Double Dispatch

  20. @hossambarakat_ Domain Events Entity Domain Events DBContext SaveChanges() Event Handler

    Handle() Event Handler Handle() Event Handler Handle() Mediator Publish() Action() SaveChangesInterceptor SavingChanges()
  21. @hossambarakat_ From Primitive Obsession to Value Objects

  22. @hossambarakat_ Where is the Repository?

  23. @hossambarakat_ Can the Unit of Work help us?

  24. @hossambarakat_ Embrace the DbContext

  25. @hossambarakat_ What about custom queries? • Query classes • Specification

    pattern • Extension Methods
  26. @hossambarakat_ Base Entity ID

  27. @hossambarakat_ Questions

  28. @hossambarakat_ Thanks Hossam Barakat Tech Lead at Willow @HossamBarakat_