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

    View Slide

  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

    View Slide

  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

    View Slide

  4. @hossambarakat_
    Strategic Design

    View Slide

  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

    View Slide

  6. @hossambarakat_
    Focus on the Core Domain

    View Slide

  7. @hossambarakat_
    Inside the Core Domain

    View Slide

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

    View Slide

  9. @hossambarakat_
    Sample Domain

    View Slide

  10. @hossambarakat_
    Sample Domain

    View Slide

  11. @hossambarakat_
    Domain Model

    View Slide

  12. @hossambarakat_
    Demo

    View Slide

  13. @hossambarakat_
    Extract Methods

    View Slide

  14. @hossambarakat_
    Avoid Public Setters

    View Slide

  15. @hossambarakat_
    Encapsulate Behavior in Domain Model

    View Slide

  16. @hossambarakat_
    Encapsulate Collection

    View Slide

  17. @hossambarakat_
    Encapsulate Behavior in Domain Model

    View Slide

  18. @hossambarakat_
    Encapsulate Behavior in Domain Service

    View Slide

  19. @hossambarakat_
    Double Dispatch

    View Slide

  20. @hossambarakat_
    Domain Events
    Entity
    Domain Events
    DBContext
    SaveChanges()
    Event Handler
    Handle()
    Event Handler
    Handle()
    Event Handler
    Handle()
    Mediator
    Publish()
    Action()
    SaveChangesInterceptor
    SavingChanges()

    View Slide

  21. @hossambarakat_
    From Primitive Obsession to Value Objects

    View Slide

  22. @hossambarakat_
    Where is the Repository?

    View Slide

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

    View Slide

  24. @hossambarakat_
    Embrace the DbContext

    View Slide

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

    View Slide

  26. @hossambarakat_
    Base Entity ID

    View Slide

  27. @hossambarakat_
    Questions

    View Slide

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

    View Slide