SlideShare a Scribd company logo
1 of 12
Download to read offline
Domain-driven
design:
Event sourcing
Eleonora Ciceri - 28 January 2022
1
Event-sourced domain model pattern
The event-sourced domain model pattern is based on the same premise as
the domain model pattern:
The difference lies in the way the aggregate state is persisted. In the
event-sourced domain model, instead of persisting the aggregate state:
2
complex, it belongs to a core subdomain
same as domain model (value objects, events, aggregates etc.)
business logic
tactical patterns
model
domain
event
generates
domain
event
domain
event
generates
generates
The events describe the changes in
the model, and are thus used as
source of truth for the aggregate’s
data
An example: potential customer management
In a telemarketing system, the customer goes through this processing cycle:
3
NEW_LEAD
potential
customer
CLOSED
person not
interested in
the offer
FOLLOWUP_SET
scheduling a
follow-up call
PENDING_PAYMENT
accepting the offer
PAYMENT_FAILED
payment ko
CONVERTED
payment ok,
person
converted into
customer
Transcribing the process into a table
If we were required to report this process into a table, we would obtain:
4
Problems of the table approach
We have a lot of information that we can extract from the table, and we can
also assume what ubiquitous language was used when modeling the table
However, the table’s data documents the current states of leads, and misses
the story of how each lead got to the current state
We can’t analyze the leads’ lifecycles only by using the table!!
5
A table is not able to model time
Solution: Event sourcing (1)
Instead of the schema reflecting the current state of the aggregates, an event
sourcing-based system persists events documenting every change in the
lifecycle of the aggregate (introducing the time dimension)
6
Solution: Event sourcing (2)
It would be like having a timeline of changes in the aggregate, that we can
retrace to understand what happened to the aggregate before getting to the
current state:
7
time
Lead initialized
Lead id: 12
User: Casey David
Contacted
Lead id: 12
Follow-up set
Lead id: 12
Contact details updated
Lead id: 12
User: Casey Davis
Storing events
All changes to an object’s state are represented and persisted as events, that
become the system’s source of truth
The accepted name for the database that is used for persisting events is
event store
8
An event store is
append-only
Advantages of event sourcing
9
Time traveling
Just as domain events can be used to
reconstitute the current state of an
aggregate, they can also be used to restore
all past states of the aggregate
Deep insight
You can add as many projections of
events as you want, leveraging the existing
data to provide additional insights
Audit log
The persisted domain events represent a
strongly consistent audit log of
everything that has happened to the
aggregates’ states
Advanced optimistic
concurrency management
We gain deeper insight into exactly what
has happened between reading the
existing events and writing new ones.
You can query events and make a business
domain-driven decision as to whether
new events collide with the attempted
operation
Disadvantages of event sourcing
10
Learning curve
There is a sharp difference from the
traditional techniques of managing data,
and this demands training of the team
and time to get used to the new way of
thinking
Evolving the model
Evolving an event-sourced model is
challenging, as events are immutable.
But what if you want to change an event’s
schema? (if interested, check “Versioning in
an event sourced system” by Greg Young)
Architectural complexity
Implementation of event sources
introduces numerous architectural moving
parts, making the overall design more
complicated
References
11
References
[1] Vlad Khononov, Learning Domain-Driven Design - Aligning Software
Architecture and Business Strategy, O’Reilly, 2022
[2] Scott Millett, Patterns, Principles and Practices of Domain Driven Design,
Wrox, 2015
[3] Vernon & Evans, Implementing Domain-Driven Design, Addison-Wesley
Professional, 2013
12

More Related Content

What's hot

Refactoring for Domain Driven Design
Refactoring for Domain Driven DesignRefactoring for Domain Driven Design
Refactoring for Domain Driven DesignDavid Berliner
 
Domain driven design and model driven development
Domain driven design and model driven developmentDomain driven design and model driven development
Domain driven design and model driven developmentDmitry Geyzersky
 
Domain Driven Design (DDD)
Domain Driven Design (DDD)Domain Driven Design (DDD)
Domain Driven Design (DDD)Tom Kocjan
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven DesignNader Albert
 
Domain Driven Design Demonstrated
Domain Driven Design Demonstrated Domain Driven Design Demonstrated
Domain Driven Design Demonstrated Alan Christensen
 
Baby steps to Domain-Driven Design
Baby steps to Domain-Driven DesignBaby steps to Domain-Driven Design
Baby steps to Domain-Driven DesignŽilvinas Kuusas
 
Metodologia orientado a objetos
Metodologia orientado a objetosMetodologia orientado a objetos
Metodologia orientado a objetosGabriel Faustino
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design Introductionwojtek_s
 
Domain-Driven Design
Domain-Driven DesignDomain-Driven Design
Domain-Driven DesignAndriy Buday
 
Azure Database Services for MySQL PostgreSQL and MariaDB
Azure Database Services for MySQL PostgreSQL and MariaDBAzure Database Services for MySQL PostgreSQL and MariaDB
Azure Database Services for MySQL PostgreSQL and MariaDBNicholas Vossburg
 
Implementing DDD with C#
Implementing DDD with C#Implementing DDD with C#
Implementing DDD with C#Pascal Laurin
 
Domain Driven Design Quickly
Domain Driven Design QuicklyDomain Driven Design Quickly
Domain Driven Design QuicklyMariam Hakobyan
 
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
 

What's hot (20)

Refactoring for Domain Driven Design
Refactoring for Domain Driven DesignRefactoring for Domain Driven Design
Refactoring for Domain Driven Design
 
Domain driven design and model driven development
Domain driven design and model driven developmentDomain driven design and model driven development
Domain driven design and model driven development
 
Domain Driven Design (DDD)
Domain Driven Design (DDD)Domain Driven Design (DDD)
Domain Driven Design (DDD)
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Domain Driven Design Demonstrated
Domain Driven Design Demonstrated Domain Driven Design Demonstrated
Domain Driven Design Demonstrated
 
Introduction to DDD
Introduction to DDDIntroduction to DDD
Introduction to DDD
 
Baby steps to Domain-Driven Design
Baby steps to Domain-Driven DesignBaby steps to Domain-Driven Design
Baby steps to Domain-Driven Design
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Domain Driven Design
Domain Driven Design Domain Driven Design
Domain Driven Design
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Metodologia orientado a objetos
Metodologia orientado a objetosMetodologia orientado a objetos
Metodologia orientado a objetos
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design Introduction
 
Domain-Driven Design
Domain-Driven DesignDomain-Driven Design
Domain-Driven Design
 
Uml
UmlUml
Uml
 
Documenting Software Architectures
Documenting Software ArchitecturesDocumenting Software Architectures
Documenting Software Architectures
 
Azure Database Services for MySQL PostgreSQL and MariaDB
Azure Database Services for MySQL PostgreSQL and MariaDBAzure Database Services for MySQL PostgreSQL and MariaDB
Azure Database Services for MySQL PostgreSQL and MariaDB
 
Implementing DDD with C#
Implementing DDD with C#Implementing DDD with C#
Implementing DDD with C#
 
Design patterns tutorials
Design patterns tutorialsDesign patterns tutorials
Design patterns tutorials
 
Domain Driven Design Quickly
Domain Driven Design QuicklyDomain Driven Design Quickly
Domain Driven Design Quickly
 
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
 

Similar to DDD - 3 - Domain Driven Design: Event sourcing.pdf

Data Governance challenges in a major Energy Company
Data Governance challenges in a major Energy CompanyData Governance challenges in a major Energy Company
Data Governance challenges in a major Energy CompanyChristopher Bradley
 
Rulemanager And Business Rules
Rulemanager And Business RulesRulemanager And Business Rules
Rulemanager And Business RulesGary Sherman
 
Modern trends in information systems
Modern trends in information systemsModern trends in information systems
Modern trends in information systemsPreeti Sontakke
 
ISAS 600 – Database Project Phase III RubricAs the final ste.docx
ISAS 600 – Database Project Phase III RubricAs the final ste.docxISAS 600 – Database Project Phase III RubricAs the final ste.docx
ISAS 600 – Database Project Phase III RubricAs the final ste.docxbagotjesusa
 
Data Mess to Data Mesh | Jay Kreps, CEO, Confluent | Kafka Summit Americas 20...
Data Mess to Data Mesh | Jay Kreps, CEO, Confluent | Kafka Summit Americas 20...Data Mess to Data Mesh | Jay Kreps, CEO, Confluent | Kafka Summit Americas 20...
Data Mess to Data Mesh | Jay Kreps, CEO, Confluent | Kafka Summit Americas 20...HostedbyConfluent
 
Wedding Hall Management 9975053592
Wedding Hall Management 9975053592Wedding Hall Management 9975053592
Wedding Hall Management 9975053592sachinc020
 
7 Emerging Data & Enterprise Integration Trends in 2022
7 Emerging Data & Enterprise Integration Trends in 20227 Emerging Data & Enterprise Integration Trends in 2022
7 Emerging Data & Enterprise Integration Trends in 2022Safe Software
 
CEP: Event-Decision Architecture for PredictiveBusiness, July 2006
CEP: Event-Decision Architecture for PredictiveBusiness, July 2006CEP: Event-Decision Architecture for PredictiveBusiness, July 2006
CEP: Event-Decision Architecture for PredictiveBusiness, July 2006Tim Bass
 
Data quality and bi
Data quality and biData quality and bi
Data quality and bijeffd00
 
Book 1 chapter-2
Book 1 chapter-2Book 1 chapter-2
Book 1 chapter-2GTU
 

Similar to DDD - 3 - Domain Driven Design: Event sourcing.pdf (20)

Data Governance challenges in a major Energy Company
Data Governance challenges in a major Energy CompanyData Governance challenges in a major Energy Company
Data Governance challenges in a major Energy Company
 
Intro to DBMS
Intro to DBMSIntro to DBMS
Intro to DBMS
 
Rulemanager
RulemanagerRulemanager
Rulemanager
 
Rulemanager And Business Rules
Rulemanager And Business RulesRulemanager And Business Rules
Rulemanager And Business Rules
 
Modern trends in information systems
Modern trends in information systemsModern trends in information systems
Modern trends in information systems
 
ISAS 600 – Database Project Phase III RubricAs the final ste.docx
ISAS 600 – Database Project Phase III RubricAs the final ste.docxISAS 600 – Database Project Phase III RubricAs the final ste.docx
ISAS 600 – Database Project Phase III RubricAs the final ste.docx
 
Systems analysis and design (abe)
Systems analysis and design (abe)Systems analysis and design (abe)
Systems analysis and design (abe)
 
Data Mess to Data Mesh | Jay Kreps, CEO, Confluent | Kafka Summit Americas 20...
Data Mess to Data Mesh | Jay Kreps, CEO, Confluent | Kafka Summit Americas 20...Data Mess to Data Mesh | Jay Kreps, CEO, Confluent | Kafka Summit Americas 20...
Data Mess to Data Mesh | Jay Kreps, CEO, Confluent | Kafka Summit Americas 20...
 
Planning Data Warehouse
Planning Data WarehousePlanning Data Warehouse
Planning Data Warehouse
 
Wedding Hall Management 9975053592
Wedding Hall Management 9975053592Wedding Hall Management 9975053592
Wedding Hall Management 9975053592
 
Cloud Storage and Security
Cloud Storage and SecurityCloud Storage and Security
Cloud Storage and Security
 
Chap06
Chap06Chap06
Chap06
 
7 Emerging Data & Enterprise Integration Trends in 2022
7 Emerging Data & Enterprise Integration Trends in 20227 Emerging Data & Enterprise Integration Trends in 2022
7 Emerging Data & Enterprise Integration Trends in 2022
 
CEP: Event-Decision Architecture for PredictiveBusiness, July 2006
CEP: Event-Decision Architecture for PredictiveBusiness, July 2006CEP: Event-Decision Architecture for PredictiveBusiness, July 2006
CEP: Event-Decision Architecture for PredictiveBusiness, July 2006
 
Data quality and bi
Data quality and biData quality and bi
Data quality and bi
 
ch01.ppt
ch01.pptch01.ppt
ch01.ppt
 
AIS-CHAPTER-1.ppt
AIS-CHAPTER-1.pptAIS-CHAPTER-1.ppt
AIS-CHAPTER-1.ppt
 
AIS-CHAPTER-1.ppt
AIS-CHAPTER-1.pptAIS-CHAPTER-1.ppt
AIS-CHAPTER-1.ppt
 
MA-26-AIS-Notes.ppt
MA-26-AIS-Notes.pptMA-26-AIS-Notes.ppt
MA-26-AIS-Notes.ppt
 
Book 1 chapter-2
Book 1 chapter-2Book 1 chapter-2
Book 1 chapter-2
 

More from Eleonora Ciceri

More from Eleonora Ciceri (14)

Artificial Intelligence: an introduction.pdf
Artificial Intelligence: an introduction.pdfArtificial Intelligence: an introduction.pdf
Artificial Intelligence: an introduction.pdf
 
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
 
Trees
TreesTrees
Trees
 
Linked lists - Exercises
Linked lists - ExercisesLinked lists - Exercises
Linked lists - Exercises
 
Doubly Linked Lists
Doubly Linked ListsDoubly Linked Lists
Doubly Linked Lists
 
Linked lists
Linked listsLinked lists
Linked lists
 
AJAX - An introduction
AJAX - An introductionAJAX - An introduction
AJAX - An introduction
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
JDBC in Servlets
JDBC in ServletsJDBC in Servlets
JDBC in Servlets
 
Client side scripting
Client side scriptingClient side scripting
Client side scripting
 
HTML5 - An introduction
HTML5 - An introductionHTML5 - An introduction
HTML5 - An introduction
 
Dynamic content generation
Dynamic content generationDynamic content generation
Dynamic content generation
 
Multimedia Information Retrieval and User Behavior
Multimedia Information Retrieval and User BehaviorMultimedia Information Retrieval and User Behavior
Multimedia Information Retrieval and User Behavior
 
The CrowdSearch framework
The CrowdSearch frameworkThe CrowdSearch framework
The CrowdSearch framework
 

Recently uploaded

Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 

Recently uploaded (20)

9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 

DDD - 3 - Domain Driven Design: Event sourcing.pdf

  • 2. Event-sourced domain model pattern The event-sourced domain model pattern is based on the same premise as the domain model pattern: The difference lies in the way the aggregate state is persisted. In the event-sourced domain model, instead of persisting the aggregate state: 2 complex, it belongs to a core subdomain same as domain model (value objects, events, aggregates etc.) business logic tactical patterns model domain event generates domain event domain event generates generates The events describe the changes in the model, and are thus used as source of truth for the aggregate’s data
  • 3. An example: potential customer management In a telemarketing system, the customer goes through this processing cycle: 3 NEW_LEAD potential customer CLOSED person not interested in the offer FOLLOWUP_SET scheduling a follow-up call PENDING_PAYMENT accepting the offer PAYMENT_FAILED payment ko CONVERTED payment ok, person converted into customer
  • 4. Transcribing the process into a table If we were required to report this process into a table, we would obtain: 4
  • 5. Problems of the table approach We have a lot of information that we can extract from the table, and we can also assume what ubiquitous language was used when modeling the table However, the table’s data documents the current states of leads, and misses the story of how each lead got to the current state We can’t analyze the leads’ lifecycles only by using the table!! 5 A table is not able to model time
  • 6. Solution: Event sourcing (1) Instead of the schema reflecting the current state of the aggregates, an event sourcing-based system persists events documenting every change in the lifecycle of the aggregate (introducing the time dimension) 6
  • 7. Solution: Event sourcing (2) It would be like having a timeline of changes in the aggregate, that we can retrace to understand what happened to the aggregate before getting to the current state: 7 time Lead initialized Lead id: 12 User: Casey David Contacted Lead id: 12 Follow-up set Lead id: 12 Contact details updated Lead id: 12 User: Casey Davis
  • 8. Storing events All changes to an object’s state are represented and persisted as events, that become the system’s source of truth The accepted name for the database that is used for persisting events is event store 8 An event store is append-only
  • 9. Advantages of event sourcing 9 Time traveling Just as domain events can be used to reconstitute the current state of an aggregate, they can also be used to restore all past states of the aggregate Deep insight You can add as many projections of events as you want, leveraging the existing data to provide additional insights Audit log The persisted domain events represent a strongly consistent audit log of everything that has happened to the aggregates’ states Advanced optimistic concurrency management We gain deeper insight into exactly what has happened between reading the existing events and writing new ones. You can query events and make a business domain-driven decision as to whether new events collide with the attempted operation
  • 10. Disadvantages of event sourcing 10 Learning curve There is a sharp difference from the traditional techniques of managing data, and this demands training of the team and time to get used to the new way of thinking Evolving the model Evolving an event-sourced model is challenging, as events are immutable. But what if you want to change an event’s schema? (if interested, check “Versioning in an event sourced system” by Greg Young) Architectural complexity Implementation of event sources introduces numerous architectural moving parts, making the overall design more complicated
  • 12. References [1] Vlad Khononov, Learning Domain-Driven Design - Aligning Software Architecture and Business Strategy, O’Reilly, 2022 [2] Scott Millett, Patterns, Principles and Practices of Domain Driven Design, Wrox, 2015 [3] Vernon & Evans, Implementing Domain-Driven Design, Addison-Wesley Professional, 2013 12