SlideShare une entreprise Scribd logo
1  sur  26
No Content Here
(Reserved for Watermark)
Decoupling with
Domain Events
@ardalis
Ardalis.com
Steve Smith
No Content Here
(Reserved for Watermark)
Pluralsight Courses
http://bit.ly/PS-ssmith
No Content Here
(Reserved for Watermark)
Repositories ✓
Factories ✓
Services ✓
Entities ✓
Value Objects ✓
Aggregates ✓
Oh yeah, Domain Events
Usually the last kid picked from
the DDD patterns I’m right
here!
No Content Here
(Reserved for Watermark)
Domain Events not covered in original DDD book (2004)
Covered by Martin Fowler in 2005
Evans published article on them in 2010
Domain-Driven Design
No Content Here
(Reserved for Watermark)
Application Events
Page Load, Button Click, Window Scroll
System Events
Restart, Backup Completed
Domain Events
Appointment Confirmed, Checkout Completed, Analysis Finished
Kinds of Events
No Content Here
(Reserved for Watermark)
Given a customer has created an order
When the customer completes their purchase
Then the customer receives an email confirmation
An example scenario
No Content Here
(Reserved for Watermark)
OrderService
Checkout(Order order)
- Save pending order in database
- Send confirmation email
An example solution
No Content Here
(Reserved for Watermark)
So far, so good
No Content Here
(Reserved for Watermark)
Given a customer has created an order
When the customer completes their purchase
Then the customer’s card is charged
And if it fails, send a different message to the customer
Then inventory is checked to ensure the order can be fulfilled
And if not a different message is sent to the customer
More requirements
No Content Here
(Reserved for Watermark)
OrderService
Checkout(Order order)
oAttempt to process payment
oIf payment fails, send notification email; exit
oSave pending order in database
oConfirm inventory is available
oIf insufficient email, send notification email; exit
oSend successful order confirmation email
An example solution
No Content Here
(Reserved for Watermark)
Complexity is growing
Must change with each new requirement
Open/Closed Principle
Checkout’s responsibilities are growing
Single Responsibility Principle
Potentially different abstraction levels (emails, order processing rules)
Analysis
No Content Here
(Reserved for Watermark)
OrderService
Checkout(Order order)
- Dispatch new OrderCompletedEvent(order)
Event Handlers:
OrderPaymentHandler
OrderInventoryHandler
OrderNotificationHandler
An event-driven solution
No Content Here
(Reserved for Watermark)
An Event
Something that happened
…that other parts of the application may need to know about
It’s a message
…which should be immutable, since it represents the past
Usually asynchronous
…especially across process boundaries
Event-Driven Programming
No Content Here
(Reserved for Watermark)
Model something that happens which is of interest to a domain expert
May lead to (or result from) a state change in a domain object
Are part of the domain model
Are usually handled synchronously within the application (but may themselves raise
events outside of the application)
Domain Events
No Content Here
(Reserved for Watermark)
Related concept – not required to take advantage of domain events
Store sequences of events rather than directly mutating object state
Determine current state by replaying events
Learn more: http://martinfowler.com/eaaDev/EventSourcing.html
Event Sourcing
No Content Here
(Reserved for Watermark)
An event is raised
Handlers within the current process handle the event
If external applications need to be notified, specific handlers can adapt and send
events to these applications as well
If unknown or future external applications will need to respond to events, a service
bus can be implemented
Event Processing
No Content Here
(Reserved for Watermark)
How do you add logic to entities that affects multiple entities?
Example:
When a customer’s total amount purchased exceeds $1000, notify a salesperson to
contact them.
Common Scenario
No Content Here
(Reserved for Watermark)
How do you add logic to entities that affects multiple entities?
Don’t solve this by using Dependency Injection on your entities. You should be able to
easily instantiate entities without dependencies.
Avoid: Injecting Dependencies into Entities
No Content Here
(Reserved for Watermark)
How do you add logic to entities that affects multiple entities?
Don’t move logic that belongs within an entity into a service just because other
entities are interested in what’s happening. This leads to the anemic domain model
antipattern.
Avoid: Shifting Entity logic to Services
No Content Here
(Reserved for Watermark)
How do you add logic to entities that affects multiple entities?
Raise a domain event to represent the action that took place.
Handle the domain event in a handler that collaborates with other entities.
Alternately, have the Aggregate Root register for events raised by members of its
Aggregate.
Use Domain Events (and perhaps Aggregates)
No Content Here
(Reserved for Watermark)
C# events
Static DomainEvents helper (Udi Dahan, 2009)
Return, don’t publish, domain events (2013)
Entity-specific event log (Jimmy Bogard, 2014)
Implementations
No Content Here
(Reserved for Watermark)
Demonstration
Implementing
Domain Events
No Content Here
(Reserved for Watermark)
Pluralsight http://bit.ly/PS-ssmith
Domain Events – Fowler http://martinfowler.com/eaaDev/DomainEvent.html
Domain Events – Evans https://domainlanguage.com/newsletter/2010-03/
Domain Events – Bogard https://lostechies.com/jimmybogard/2010/04/08/strengthening-your-
domain-domain-events/
Implementations
Udi Dahan – http://www.udidahan.com/2009/06/14/domain-events-salvation/
Jimmy Bogard – https://lostechies.com/jimmybogard/2014/05/13/a-better-domain-events-pattern/
Jay Kronquist - http://www.jayway.com/2013/06/20/dont-publish-domain-events-return-them/
References
No Content Here
(Reserved for Watermark)
New Coworking Space in Hudson, Ohio
Private offices / Flex desk spaces
Fiber internet
Complimentary coffee / tea / water
Great development community
@techhubhudson
Website online soon
Tech Hub Hudson
No Content Here
(Reserved for Watermark)
Kickstarter Successful
Available November 2016
Order now:
store.DevIQ.com
2017 Software Craftsmanship Calendar
No Content Here
(Reserved for Watermark)
No Content Here
(Reserved for Watermark)
No Content Here
(Reserved for Course Previews)
Thanks!
Follow us:
/DevIQPage
DevIQ.com/updates
@deviq
• full-length courses
• samples
• member-only events
Enroll in DevIQ for access to:
DevIQ.com/enroll
Ardalis.com
@ardalis
Steve Smith

Contenu connexe

Tendances

Hexagonal architecture - message-oriented software design
Hexagonal architecture  - message-oriented software designHexagonal architecture  - message-oriented software design
Hexagonal architecture - message-oriented software designMatthias Noback
 
The quest for global design principles - PHP Benelux 2016
The quest for global design principles - PHP Benelux 2016The quest for global design principles - PHP Benelux 2016
The quest for global design principles - PHP Benelux 2016Matthias Noback
 
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (BDDx L...
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (BDDx L...Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (BDDx L...
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (BDDx L...Gáspár Nagy
 
Stuff About CQRS
Stuff About CQRSStuff About CQRS
Stuff About CQRSthinkddd
 
O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
O365Con18 - Automate your Tasks through Azure Functions - Elio StruyfO365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
O365Con18 - Automate your Tasks through Azure Functions - Elio StruyfNCCOMMS
 
An Introduction to Reactive Application, Reactive Streams, and options for JVM
An Introduction to Reactive Application, Reactive Streams, and options for JVMAn Introduction to Reactive Application, Reactive Streams, and options for JVM
An Introduction to Reactive Application, Reactive Streams, and options for JVMSteve Pember
 
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016Roy de Kleijn
 
Reactive Development: Commands, Actors and Events. Oh My!!
Reactive Development: Commands, Actors and Events.  Oh My!!Reactive Development: Commands, Actors and Events.  Oh My!!
Reactive Development: Commands, Actors and Events. Oh My!!David Hoerster
 
Dead-Simple Deployment: Headache-Free Java Web Applications in the Cloud
Dead-Simple Deployment: Headache-Free Java Web Applications in the CloudDead-Simple Deployment: Headache-Free Java Web Applications in the Cloud
Dead-Simple Deployment: Headache-Free Java Web Applications in the CloudCraig Dickson
 
Clean architecture with ddd layering in php
Clean architecture with ddd layering in phpClean architecture with ddd layering in php
Clean architecture with ddd layering in phpLeonardo Proietti
 
20160609 nike techtalks reactive applications tools of the trade
20160609 nike techtalks reactive applications   tools of the trade20160609 nike techtalks reactive applications   tools of the trade
20160609 nike techtalks reactive applications tools of the tradeshinolajla
 
Single Page Applications: Your Browser is the OS!
Single Page Applications: Your Browser is the OS!Single Page Applications: Your Browser is the OS!
Single Page Applications: Your Browser is the OS!Jeremy Likness
 
Behaviour driven development aka bdd
Behaviour driven development aka bddBehaviour driven development aka bdd
Behaviour driven development aka bddPrince Gupta
 
Event Sourcing from the Trenches (with examples from .NET)
Event Sourcing from the Trenches (with examples from .NET)Event Sourcing from the Trenches (with examples from .NET)
Event Sourcing from the Trenches (with examples from .NET)Dennis Doomen
 
Behavior Driven Development (BDD) and Agile Testing
Behavior Driven Development (BDD) and Agile TestingBehavior Driven Development (BDD) and Agile Testing
Behavior Driven Development (BDD) and Agile Testingdversaci
 
SharePoint PowerShell for the Admin and Developer - A Venn Diagram Experience
SharePoint PowerShell for the Admin and Developer - A Venn Diagram ExperienceSharePoint PowerShell for the Admin and Developer - A Venn Diagram Experience
SharePoint PowerShell for the Admin and Developer - A Venn Diagram ExperienceRicardo Wilkins
 
Fast Cordova applications
Fast Cordova applicationsFast Cordova applications
Fast Cordova applicationsIvano Malavolta
 
Greenfield Development with CQRS
Greenfield Development with CQRSGreenfield Development with CQRS
Greenfield Development with CQRSDavid Hoerster
 
CQRS and what it means for your architecture
CQRS and what it means for your architectureCQRS and what it means for your architecture
CQRS and what it means for your architectureRichard Banks
 

Tendances (20)

Hexagonal architecture - message-oriented software design
Hexagonal architecture  - message-oriented software designHexagonal architecture  - message-oriented software design
Hexagonal architecture - message-oriented software design
 
The quest for global design principles - PHP Benelux 2016
The quest for global design principles - PHP Benelux 2016The quest for global design principles - PHP Benelux 2016
The quest for global design principles - PHP Benelux 2016
 
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (BDDx L...
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (BDDx L...Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (BDDx L...
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (BDDx L...
 
CQRS and Event Sourcing
CQRS and Event SourcingCQRS and Event Sourcing
CQRS and Event Sourcing
 
Stuff About CQRS
Stuff About CQRSStuff About CQRS
Stuff About CQRS
 
O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
O365Con18 - Automate your Tasks through Azure Functions - Elio StruyfO365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
 
An Introduction to Reactive Application, Reactive Streams, and options for JVM
An Introduction to Reactive Application, Reactive Streams, and options for JVMAn Introduction to Reactive Application, Reactive Streams, and options for JVM
An Introduction to Reactive Application, Reactive Streams, and options for JVM
 
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
 
Reactive Development: Commands, Actors and Events. Oh My!!
Reactive Development: Commands, Actors and Events.  Oh My!!Reactive Development: Commands, Actors and Events.  Oh My!!
Reactive Development: Commands, Actors and Events. Oh My!!
 
Dead-Simple Deployment: Headache-Free Java Web Applications in the Cloud
Dead-Simple Deployment: Headache-Free Java Web Applications in the CloudDead-Simple Deployment: Headache-Free Java Web Applications in the Cloud
Dead-Simple Deployment: Headache-Free Java Web Applications in the Cloud
 
Clean architecture with ddd layering in php
Clean architecture with ddd layering in phpClean architecture with ddd layering in php
Clean architecture with ddd layering in php
 
20160609 nike techtalks reactive applications tools of the trade
20160609 nike techtalks reactive applications   tools of the trade20160609 nike techtalks reactive applications   tools of the trade
20160609 nike techtalks reactive applications tools of the trade
 
Single Page Applications: Your Browser is the OS!
Single Page Applications: Your Browser is the OS!Single Page Applications: Your Browser is the OS!
Single Page Applications: Your Browser is the OS!
 
Behaviour driven development aka bdd
Behaviour driven development aka bddBehaviour driven development aka bdd
Behaviour driven development aka bdd
 
Event Sourcing from the Trenches (with examples from .NET)
Event Sourcing from the Trenches (with examples from .NET)Event Sourcing from the Trenches (with examples from .NET)
Event Sourcing from the Trenches (with examples from .NET)
 
Behavior Driven Development (BDD) and Agile Testing
Behavior Driven Development (BDD) and Agile TestingBehavior Driven Development (BDD) and Agile Testing
Behavior Driven Development (BDD) and Agile Testing
 
SharePoint PowerShell for the Admin and Developer - A Venn Diagram Experience
SharePoint PowerShell for the Admin and Developer - A Venn Diagram ExperienceSharePoint PowerShell for the Admin and Developer - A Venn Diagram Experience
SharePoint PowerShell for the Admin and Developer - A Venn Diagram Experience
 
Fast Cordova applications
Fast Cordova applicationsFast Cordova applications
Fast Cordova applications
 
Greenfield Development with CQRS
Greenfield Development with CQRSGreenfield Development with CQRS
Greenfield Development with CQRS
 
CQRS and what it means for your architecture
CQRS and what it means for your architectureCQRS and what it means for your architecture
CQRS and what it means for your architecture
 

En vedette

Functional and Event Driven - another approach to domain modeling
Functional and Event Driven - another approach to domain modelingFunctional and Event Driven - another approach to domain modeling
Functional and Event Driven - another approach to domain modelingDebasish Ghosh
 
Day 2: Innovation in parliaments #2, Mr. Fakhreddine Aouadi, Innovation Offic...
Day 2: Innovation in parliaments #2, Mr. Fakhreddine Aouadi, Innovation Offic...Day 2: Innovation in parliaments #2, Mr. Fakhreddine Aouadi, Innovation Offic...
Day 2: Innovation in parliaments #2, Mr. Fakhreddine Aouadi, Innovation Offic...wepc2016
 
Building occasionally connected applications using event sourcing
Building occasionally connected applications using event sourcingBuilding occasionally connected applications using event sourcing
Building occasionally connected applications using event sourcingDennis Doomen
 
Functional Programming & Event Sourcing - a pair made in heaven
Functional Programming & Event Sourcing - a pair made in heavenFunctional Programming & Event Sourcing - a pair made in heaven
Functional Programming & Event Sourcing - a pair made in heavenPawel Szulc
 
рентабельный код
рентабельный кодрентабельный код
рентабельный кодMax Arshinov
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven DesignRyan Riley
 
DDD Framework for Java: JdonFramework
DDD Framework for Java: JdonFrameworkDDD Framework for Java: JdonFramework
DDD Framework for Java: JdonFrameworkbanq jdon
 
CQRS and Event Sourcing, An Alternative Architecture for DDD
CQRS and Event Sourcing, An Alternative Architecture for DDDCQRS and Event Sourcing, An Alternative Architecture for DDD
CQRS and Event Sourcing, An Alternative Architecture for DDDDennis Doomen
 
A Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation SlidesA Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation Slidesthinkddd
 

En vedette (10)

Functional and Event Driven - another approach to domain modeling
Functional and Event Driven - another approach to domain modelingFunctional and Event Driven - another approach to domain modeling
Functional and Event Driven - another approach to domain modeling
 
Day 2: Innovation in parliaments #2, Mr. Fakhreddine Aouadi, Innovation Offic...
Day 2: Innovation in parliaments #2, Mr. Fakhreddine Aouadi, Innovation Offic...Day 2: Innovation in parliaments #2, Mr. Fakhreddine Aouadi, Innovation Offic...
Day 2: Innovation in parliaments #2, Mr. Fakhreddine Aouadi, Innovation Offic...
 
Building occasionally connected applications using event sourcing
Building occasionally connected applications using event sourcingBuilding occasionally connected applications using event sourcing
Building occasionally connected applications using event sourcing
 
CQRS is not Event Sourcing
CQRS is not Event SourcingCQRS is not Event Sourcing
CQRS is not Event Sourcing
 
Functional Programming & Event Sourcing - a pair made in heaven
Functional Programming & Event Sourcing - a pair made in heavenFunctional Programming & Event Sourcing - a pair made in heaven
Functional Programming & Event Sourcing - a pair made in heaven
 
рентабельный код
рентабельный кодрентабельный код
рентабельный код
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
DDD Framework for Java: JdonFramework
DDD Framework for Java: JdonFrameworkDDD Framework for Java: JdonFramework
DDD Framework for Java: JdonFramework
 
CQRS and Event Sourcing, An Alternative Architecture for DDD
CQRS and Event Sourcing, An Alternative Architecture for DDDCQRS and Event Sourcing, An Alternative Architecture for DDD
CQRS and Event Sourcing, An Alternative Architecture for DDD
 
A Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation SlidesA Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation Slides
 

Similaire à Decoupling with Domain Events

Introducing Domain Driven Design - codemash
Introducing Domain Driven Design - codemashIntroducing Domain Driven Design - codemash
Introducing Domain Driven Design - codemashSteven Smith
 
Introducing domain driven design - dogfood con 2018
Introducing domain driven design - dogfood con 2018Introducing domain driven design - dogfood con 2018
Introducing domain driven design - dogfood con 2018Steven Smith
 
Event storming Notes
Event storming NotesEvent storming Notes
Event storming NotesArnauld Loyer
 
Seminar - Scalable Enterprise Application Development Using DDD and CQRS
Seminar - Scalable Enterprise Application Development Using DDD and CQRSSeminar - Scalable Enterprise Application Development Using DDD and CQRS
Seminar - Scalable Enterprise Application Development Using DDD and CQRSMizanur Sarker
 
RailswayCon 2010 - Command Your Domain
RailswayCon 2010 - Command Your DomainRailswayCon 2010 - Command Your Domain
RailswayCon 2010 - Command Your DomainLourens Naudé
 
Microservices with .Net - NDC Sydney, 2016
Microservices with .Net - NDC Sydney, 2016Microservices with .Net - NDC Sydney, 2016
Microservices with .Net - NDC Sydney, 2016Richard Banks
 
Long running processes in DDD
Long running processes in DDDLong running processes in DDD
Long running processes in DDDBernd Ruecker
 
Detial process description inter company stock transfer
Detial process description inter company stock transferDetial process description inter company stock transfer
Detial process description inter company stock transferMuhammad Zafar Firoz
 
Less03 2 e_testermodule_2
Less03 2 e_testermodule_2Less03 2 e_testermodule_2
Less03 2 e_testermodule_2Suresh Mishra
 
A practical introduction to Event Sourcing and CQRS
A practical introduction to Event Sourcing and CQRSA practical introduction to Event Sourcing and CQRS
A practical introduction to Event Sourcing and CQRSRobert Lemke
 
Eda on the azure services platform
Eda on the azure services platformEda on the azure services platform
Eda on the azure services platformYves Goeleven
 
Hazelcast Striim Hot Cache Presentation
Hazelcast Striim Hot Cache PresentationHazelcast Striim Hot Cache Presentation
Hazelcast Striim Hot Cache PresentationSteve Wilkes
 
The Good, The Bad and The Ugly of Event Sourcing
The Good, The Bad and The Ugly of Event Sourcing The Good, The Bad and The Ugly of Event Sourcing
The Good, The Bad and The Ugly of Event Sourcing Dennis Doomen
 
Dynamic Actions, the Hard Parts
Dynamic Actions, the Hard PartsDynamic Actions, the Hard Parts
Dynamic Actions, the Hard PartsDaniel McGhan
 
Process mining with Disco (Eng)
Process mining with Disco (Eng)Process mining with Disco (Eng)
Process mining with Disco (Eng)Dafna Levy
 
Crafted Design - LJC World Tour Mash Up 2014
Crafted Design - LJC World Tour Mash Up 2014Crafted Design - LJC World Tour Mash Up 2014
Crafted Design - LJC World Tour Mash Up 2014Sandro Mancuso
 
Crafted Design - Sandro Mancuso
Crafted Design - Sandro MancusoCrafted Design - Sandro Mancuso
Crafted Design - Sandro MancusoJAXLondon2014
 
The art of the state
The art of the stateThe art of the state
The art of the stateIlyas Bakouch
 
TAG Presents: NetSuite SuiteFlow 101
TAG Presents: NetSuite SuiteFlow 101 TAG Presents: NetSuite SuiteFlow 101
TAG Presents: NetSuite SuiteFlow 101 TAG
 

Similaire à Decoupling with Domain Events (20)

Introducing Domain Driven Design - codemash
Introducing Domain Driven Design - codemashIntroducing Domain Driven Design - codemash
Introducing Domain Driven Design - codemash
 
Introducing domain driven design - dogfood con 2018
Introducing domain driven design - dogfood con 2018Introducing domain driven design - dogfood con 2018
Introducing domain driven design - dogfood con 2018
 
Event storming Notes
Event storming NotesEvent storming Notes
Event storming Notes
 
Seminar - Scalable Enterprise Application Development Using DDD and CQRS
Seminar - Scalable Enterprise Application Development Using DDD and CQRSSeminar - Scalable Enterprise Application Development Using DDD and CQRS
Seminar - Scalable Enterprise Application Development Using DDD and CQRS
 
RailswayCon 2010 - Command Your Domain
RailswayCon 2010 - Command Your DomainRailswayCon 2010 - Command Your Domain
RailswayCon 2010 - Command Your Domain
 
Microservices with .Net - NDC Sydney, 2016
Microservices with .Net - NDC Sydney, 2016Microservices with .Net - NDC Sydney, 2016
Microservices with .Net - NDC Sydney, 2016
 
Long running processes in DDD
Long running processes in DDDLong running processes in DDD
Long running processes in DDD
 
Detial process description inter company stock transfer
Detial process description inter company stock transferDetial process description inter company stock transfer
Detial process description inter company stock transfer
 
Less03 2 e_testermodule_2
Less03 2 e_testermodule_2Less03 2 e_testermodule_2
Less03 2 e_testermodule_2
 
A practical introduction to Event Sourcing and CQRS
A practical introduction to Event Sourcing and CQRSA practical introduction to Event Sourcing and CQRS
A practical introduction to Event Sourcing and CQRS
 
Eda on the azure services platform
Eda on the azure services platformEda on the azure services platform
Eda on the azure services platform
 
Hazelcast Striim Hot Cache Presentation
Hazelcast Striim Hot Cache PresentationHazelcast Striim Hot Cache Presentation
Hazelcast Striim Hot Cache Presentation
 
The Good, The Bad and The Ugly of Event Sourcing
The Good, The Bad and The Ugly of Event Sourcing The Good, The Bad and The Ugly of Event Sourcing
The Good, The Bad and The Ugly of Event Sourcing
 
Dynamic Actions, the Hard Parts
Dynamic Actions, the Hard PartsDynamic Actions, the Hard Parts
Dynamic Actions, the Hard Parts
 
Process mining with Disco (Eng)
Process mining with Disco (Eng)Process mining with Disco (Eng)
Process mining with Disco (Eng)
 
Crafted Design - LJC World Tour Mash Up 2014
Crafted Design - LJC World Tour Mash Up 2014Crafted Design - LJC World Tour Mash Up 2014
Crafted Design - LJC World Tour Mash Up 2014
 
Crafted Design - Sandro Mancuso
Crafted Design - Sandro MancusoCrafted Design - Sandro Mancuso
Crafted Design - Sandro Mancuso
 
The art of the state
The art of the stateThe art of the state
The art of the state
 
Large Data Management Strategies
Large Data Management StrategiesLarge Data Management Strategies
Large Data Management Strategies
 
TAG Presents: NetSuite SuiteFlow 101
TAG Presents: NetSuite SuiteFlow 101 TAG Presents: NetSuite SuiteFlow 101
TAG Presents: NetSuite SuiteFlow 101
 

Plus de Steven Smith

Clean architecture with asp.net core by Ardalis
Clean architecture with asp.net core by ArdalisClean architecture with asp.net core by Ardalis
Clean architecture with asp.net core by ArdalisSteven Smith
 
Finding Patterns in the Clouds - Cloud Design Patterns
Finding Patterns in the Clouds - Cloud Design PatternsFinding Patterns in the Clouds - Cloud Design Patterns
Finding Patterns in the Clouds - Cloud Design PatternsSteven Smith
 
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018Steven Smith
 
Most Useful Design Patterns
Most Useful Design PatternsMost Useful Design Patterns
Most Useful Design PatternsSteven Smith
 
Improving the Design of Existing Software
Improving the Design of Existing SoftwareImproving the Design of Existing Software
Improving the Design of Existing SoftwareSteven Smith
 
Introducing ASP.NET Core 2.0
Introducing ASP.NET Core 2.0Introducing ASP.NET Core 2.0
Introducing ASP.NET Core 2.0Steven Smith
 
Improving the Quality of Existing Software
Improving the Quality of Existing SoftwareImproving the Quality of Existing Software
Improving the Quality of Existing SoftwareSteven Smith
 
Improving the Quality of Existing Software
Improving the Quality of Existing SoftwareImproving the Quality of Existing Software
Improving the Quality of Existing SoftwareSteven Smith
 
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016Steven Smith
 
Improving the Quality of Existing Software - DevIntersection April 2016
Improving the Quality of Existing Software - DevIntersection April 2016Improving the Quality of Existing Software - DevIntersection April 2016
Improving the Quality of Existing Software - DevIntersection April 2016Steven Smith
 
Breaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit TestingBreaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit TestingSteven Smith
 
Improving the Quality of Existing Software
Improving the Quality of Existing SoftwareImproving the Quality of Existing Software
Improving the Quality of Existing SoftwareSteven Smith
 
A Whirldwind Tour of ASP.NET 5
A Whirldwind Tour of ASP.NET 5A Whirldwind Tour of ASP.NET 5
A Whirldwind Tour of ASP.NET 5Steven Smith
 
My Iraq Experience
My Iraq ExperienceMy Iraq Experience
My Iraq ExperienceSteven Smith
 
Breaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit TestingBreaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit TestingSteven Smith
 
Improving The Quality of Existing Software
Improving The Quality of Existing SoftwareImproving The Quality of Existing Software
Improving The Quality of Existing SoftwareSteven Smith
 
Refactoring with SOLID Principles (FalafelCon 2013)
Refactoring with SOLID Principles (FalafelCon 2013)Refactoring with SOLID Principles (FalafelCon 2013)
Refactoring with SOLID Principles (FalafelCon 2013)Steven Smith
 
Common ASP.NET Design Patterns - Telerik India DevCon 2013
Common ASP.NET Design Patterns - Telerik India DevCon 2013Common ASP.NET Design Patterns - Telerik India DevCon 2013
Common ASP.NET Design Patterns - Telerik India DevCon 2013Steven Smith
 
Refactoring with SOLID - Telerik India DevCon 2013
Refactoring with SOLID - Telerik India DevCon 2013Refactoring with SOLID - Telerik India DevCon 2013
Refactoring with SOLID - Telerik India DevCon 2013Steven Smith
 

Plus de Steven Smith (20)

Clean architecture with asp.net core by Ardalis
Clean architecture with asp.net core by ArdalisClean architecture with asp.net core by Ardalis
Clean architecture with asp.net core by Ardalis
 
Finding Patterns in the Clouds - Cloud Design Patterns
Finding Patterns in the Clouds - Cloud Design PatternsFinding Patterns in the Clouds - Cloud Design Patterns
Finding Patterns in the Clouds - Cloud Design Patterns
 
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
 
Most Useful Design Patterns
Most Useful Design PatternsMost Useful Design Patterns
Most Useful Design Patterns
 
Improving the Design of Existing Software
Improving the Design of Existing SoftwareImproving the Design of Existing Software
Improving the Design of Existing Software
 
Introducing ASP.NET Core 2.0
Introducing ASP.NET Core 2.0Introducing ASP.NET Core 2.0
Introducing ASP.NET Core 2.0
 
Improving the Quality of Existing Software
Improving the Quality of Existing SoftwareImproving the Quality of Existing Software
Improving the Quality of Existing Software
 
Improving the Quality of Existing Software
Improving the Quality of Existing SoftwareImproving the Quality of Existing Software
Improving the Quality of Existing Software
 
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
 
Improving the Quality of Existing Software - DevIntersection April 2016
Improving the Quality of Existing Software - DevIntersection April 2016Improving the Quality of Existing Software - DevIntersection April 2016
Improving the Quality of Existing Software - DevIntersection April 2016
 
Breaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit TestingBreaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit Testing
 
Improving the Quality of Existing Software
Improving the Quality of Existing SoftwareImproving the Quality of Existing Software
Improving the Quality of Existing Software
 
A Whirldwind Tour of ASP.NET 5
A Whirldwind Tour of ASP.NET 5A Whirldwind Tour of ASP.NET 5
A Whirldwind Tour of ASP.NET 5
 
Domain events
Domain eventsDomain events
Domain events
 
My Iraq Experience
My Iraq ExperienceMy Iraq Experience
My Iraq Experience
 
Breaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit TestingBreaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit Testing
 
Improving The Quality of Existing Software
Improving The Quality of Existing SoftwareImproving The Quality of Existing Software
Improving The Quality of Existing Software
 
Refactoring with SOLID Principles (FalafelCon 2013)
Refactoring with SOLID Principles (FalafelCon 2013)Refactoring with SOLID Principles (FalafelCon 2013)
Refactoring with SOLID Principles (FalafelCon 2013)
 
Common ASP.NET Design Patterns - Telerik India DevCon 2013
Common ASP.NET Design Patterns - Telerik India DevCon 2013Common ASP.NET Design Patterns - Telerik India DevCon 2013
Common ASP.NET Design Patterns - Telerik India DevCon 2013
 
Refactoring with SOLID - Telerik India DevCon 2013
Refactoring with SOLID - Telerik India DevCon 2013Refactoring with SOLID - Telerik India DevCon 2013
Refactoring with SOLID - Telerik India DevCon 2013
 

Dernier

Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 

Dernier (20)

Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 

Decoupling with Domain Events

  • 1. No Content Here (Reserved for Watermark) Decoupling with Domain Events @ardalis Ardalis.com Steve Smith
  • 2. No Content Here (Reserved for Watermark) Pluralsight Courses http://bit.ly/PS-ssmith
  • 3. No Content Here (Reserved for Watermark) Repositories ✓ Factories ✓ Services ✓ Entities ✓ Value Objects ✓ Aggregates ✓ Oh yeah, Domain Events Usually the last kid picked from the DDD patterns I’m right here!
  • 4. No Content Here (Reserved for Watermark) Domain Events not covered in original DDD book (2004) Covered by Martin Fowler in 2005 Evans published article on them in 2010 Domain-Driven Design
  • 5. No Content Here (Reserved for Watermark) Application Events Page Load, Button Click, Window Scroll System Events Restart, Backup Completed Domain Events Appointment Confirmed, Checkout Completed, Analysis Finished Kinds of Events
  • 6. No Content Here (Reserved for Watermark) Given a customer has created an order When the customer completes their purchase Then the customer receives an email confirmation An example scenario
  • 7. No Content Here (Reserved for Watermark) OrderService Checkout(Order order) - Save pending order in database - Send confirmation email An example solution
  • 8. No Content Here (Reserved for Watermark) So far, so good
  • 9. No Content Here (Reserved for Watermark) Given a customer has created an order When the customer completes their purchase Then the customer’s card is charged And if it fails, send a different message to the customer Then inventory is checked to ensure the order can be fulfilled And if not a different message is sent to the customer More requirements
  • 10. No Content Here (Reserved for Watermark) OrderService Checkout(Order order) oAttempt to process payment oIf payment fails, send notification email; exit oSave pending order in database oConfirm inventory is available oIf insufficient email, send notification email; exit oSend successful order confirmation email An example solution
  • 11. No Content Here (Reserved for Watermark) Complexity is growing Must change with each new requirement Open/Closed Principle Checkout’s responsibilities are growing Single Responsibility Principle Potentially different abstraction levels (emails, order processing rules) Analysis
  • 12. No Content Here (Reserved for Watermark) OrderService Checkout(Order order) - Dispatch new OrderCompletedEvent(order) Event Handlers: OrderPaymentHandler OrderInventoryHandler OrderNotificationHandler An event-driven solution
  • 13. No Content Here (Reserved for Watermark) An Event Something that happened …that other parts of the application may need to know about It’s a message …which should be immutable, since it represents the past Usually asynchronous …especially across process boundaries Event-Driven Programming
  • 14. No Content Here (Reserved for Watermark) Model something that happens which is of interest to a domain expert May lead to (or result from) a state change in a domain object Are part of the domain model Are usually handled synchronously within the application (but may themselves raise events outside of the application) Domain Events
  • 15. No Content Here (Reserved for Watermark) Related concept – not required to take advantage of domain events Store sequences of events rather than directly mutating object state Determine current state by replaying events Learn more: http://martinfowler.com/eaaDev/EventSourcing.html Event Sourcing
  • 16. No Content Here (Reserved for Watermark) An event is raised Handlers within the current process handle the event If external applications need to be notified, specific handlers can adapt and send events to these applications as well If unknown or future external applications will need to respond to events, a service bus can be implemented Event Processing
  • 17. No Content Here (Reserved for Watermark) How do you add logic to entities that affects multiple entities? Example: When a customer’s total amount purchased exceeds $1000, notify a salesperson to contact them. Common Scenario
  • 18. No Content Here (Reserved for Watermark) How do you add logic to entities that affects multiple entities? Don’t solve this by using Dependency Injection on your entities. You should be able to easily instantiate entities without dependencies. Avoid: Injecting Dependencies into Entities
  • 19. No Content Here (Reserved for Watermark) How do you add logic to entities that affects multiple entities? Don’t move logic that belongs within an entity into a service just because other entities are interested in what’s happening. This leads to the anemic domain model antipattern. Avoid: Shifting Entity logic to Services
  • 20. No Content Here (Reserved for Watermark) How do you add logic to entities that affects multiple entities? Raise a domain event to represent the action that took place. Handle the domain event in a handler that collaborates with other entities. Alternately, have the Aggregate Root register for events raised by members of its Aggregate. Use Domain Events (and perhaps Aggregates)
  • 21. No Content Here (Reserved for Watermark) C# events Static DomainEvents helper (Udi Dahan, 2009) Return, don’t publish, domain events (2013) Entity-specific event log (Jimmy Bogard, 2014) Implementations
  • 22. No Content Here (Reserved for Watermark) Demonstration Implementing Domain Events
  • 23. No Content Here (Reserved for Watermark) Pluralsight http://bit.ly/PS-ssmith Domain Events – Fowler http://martinfowler.com/eaaDev/DomainEvent.html Domain Events – Evans https://domainlanguage.com/newsletter/2010-03/ Domain Events – Bogard https://lostechies.com/jimmybogard/2010/04/08/strengthening-your- domain-domain-events/ Implementations Udi Dahan – http://www.udidahan.com/2009/06/14/domain-events-salvation/ Jimmy Bogard – https://lostechies.com/jimmybogard/2014/05/13/a-better-domain-events-pattern/ Jay Kronquist - http://www.jayway.com/2013/06/20/dont-publish-domain-events-return-them/ References
  • 24. No Content Here (Reserved for Watermark) New Coworking Space in Hudson, Ohio Private offices / Flex desk spaces Fiber internet Complimentary coffee / tea / water Great development community @techhubhudson Website online soon Tech Hub Hudson
  • 25. No Content Here (Reserved for Watermark) Kickstarter Successful Available November 2016 Order now: store.DevIQ.com 2017 Software Craftsmanship Calendar
  • 26. No Content Here (Reserved for Watermark) No Content Here (Reserved for Watermark) No Content Here (Reserved for Course Previews) Thanks! Follow us: /DevIQPage DevIQ.com/updates @deviq • full-length courses • samples • member-only events Enroll in DevIQ for access to: DevIQ.com/enroll Ardalis.com @ardalis Steve Smith

Notes de l'éditeur

  1. Domain Events d
  2. Model object – typically an entity.
  3. Implementing this kind of logic directly within the Customer or Order entity is cumbersome. Moving it into a service may result in an anemic domain model.
  4. Implementing this kind of logic directly within the Customer or Order entity is cumbersome. Moving it into a service may result in an anemic domain model.
  5. Implementing this kind of logic directly within the Customer or Order entity is cumbersome. Moving it into a service may result in an anemic domain model.
  6. Show Domain Events Demo Tests – LanguageEvents Udi Domain Events DbContextSaveChangesShould Show Domain Events Console Walk through and run Show Vet Clinic App