SlideShare une entreprise Scribd logo
1  sur  33
Télécharger pour lire hors ligne
A CQRS journey
An introduction to Hexagonal Software Architectural Patterns,
DDD & CQRS
Who are we?
Thanos Nokas
Software Engineer
Human Factor
Thanos Korakas
Web Developer
Human Factor
Sotiris Gkanouris
Engineering Manager
MessageBird
Chrysovalantis Koutsoumpos
Software Engineer
Special thanks*
Alberto Perego
George Tsiatzios
Sebastiaan Schinkel
* alphabetically
Where are we?
SocialNerds Amsterdam branch
Greek Digital Community (slack workspace)
Disclaimer
This presentation targets a broader audience and means to be
seniority/experience agnostic.
Its aim is to make a simple introduction to complex architectures providing with
enough information to get started with them.
Many structures, elements and steps are stripped in favour of simplicity.
It is build with a step-by-step approach, in a way that everyone can follow.
Software Architecture
● Fundamental structural choices
● Elements inside those structures
● Properties of the elements
● Responsibility of each element
● Relations between elements
● Constraints between structures and elements
“The way that we are
organizing our project’s
structure and establishing
communication between its
elements”
Architectural Patterns
● Reusable solution to a commonly occurring problem
● With focus on
○ performance
○ code quality
○ code reusability
○ infrastructure limitations,
○ high availability
○ minimization of a business risk
○ security
● Similar with (code) design patterns but with a broader scope
“An already proven set of
predefined structural, relation
and constraint choices”
Software architecture chronicles
● 50s: Non structured programming
● 60s: Structured programming
○ Tier 1
● 1979: Procedural / Functional programming
○ Model View Controller (MVC)
● 80s: Object oriented programming
○ Tier 2
● 1997: Web services, ESB
● 2003: Domain Driven Design (DDD)
● 2005: Hexagonal (AKA Ports & Adapters)
● 2006: Command Query Responsibility Segregation (CQRS), Event Sourcing
● 2008: Onion
● 2009: Microservices
● 2012: Clean
A software project may use a combination of more than one architectural patterns
Hexagonal architecture
inside
application
and
business
logic
outside
UI and
Infrastructure
outside
UI and
Infrastructure
2005 - Alistair Cockburn
Ports, adapters & adaptees
● A target is an object that we want to
● communicate with
● A port is an entry point. It defines a set of
functions.
● An adapter is a bridge between the application
and the service that is needed by the
application. It fits a specific port.
● An adaptee the element that uses an adapter
to communicate with a port.
● Think of your phone charger
○ Your phone is the Adaptee
○ The USB Adapter is the ...Adapter
○ The socket is the Target and it’s facade is Port
GoF - Adapter Pattern
use case
use case
Ports & Adapters
Message Broker
Adapter
Persistence
Adapter
Adapter
Adaptee
HTTP
use case
Port
Adaptee
Adaptee
Adaptee
Adapter
Adapter
Adapter
Port
inside
application
and
business
logic
outside
Infrastructure
outside
UI
HTTP Adapter
CLI Adapter
> CLI
DB
Message Broker
UI & Infrastructure abstractions
Port
use case
Port
2008 - Jeffrey Palermo
inside
application
and
business
logic
outside
UI and
Infrastructure
outside
UI and
Infrastructure
Onion architecture
Domain Model
Application Services
UI / Infrastructure
2008 - Jeffrey Palermo
Domain Services
Dependency goes inwards
Outer layers depend on inner layers
Inner layers do not know about outer layers
Domain, Application, API, UI and Infrastructure
● Domain Model Layer — Contains all business logic, the Entities, Events and any other object type that contains Business Logic
● Application Services Layer — Orchestrates Domain objects to perform tasks required by the end users
● User Interface Layer — Displays some data to end users and where end users interact with the system
● Infrastructure Layer — Technical capabilities that support the layers above, e.g. persistence or messaging
Domain
Application
can not communicate
can communicate
UI / Infrastructure
Domain
Application
UI / Infrastructure
can not communicate
can communicate
Domain
Application
UI / Infrastructure
can not communicate
can communicate
Domain Model
Application Services
UI / Infrastructure
Domain Services
Onion, a superset of Hexagonal
The evolution of Ports & Adapters
DB
Message Broker
HTTP
> CLI
Driving / Driven Adapters
Message
Broker
Adapter
Persistence
Adapter
Secondary/
Driven Port
Port
Port
PortPort
Primary /
Driving Adapter
Secondary/
Driven Adapter
Domain
Application
UI / Infrastructure
Webport
CLIport
Messagingport
Persistenceport
HTTP
> CLI DB
Message Broker
CLI Adapter
HTTPAdapter
Primary /
Driving Port
Domain
Application
UI/Infrastructure
High level comparison with MVC
Controller
Model ViewDB
Domain
Application
UI/Infrastructure
Horizontal view
Application
Driven Adapter
(Infrastructure)
Domain
Driving Adapter
(UI)
Vertical view
(via the)
Application
DB
GUI
(via the same)
Application
Application
Driven Adapter
(Infrastructure)
DB
Driving Adapter
(UI)
The separation of read and write flows
one way
Write flow
Two way
Read flow
Write Domain
GUI
Read Domain
What is CQRS
● An architectural pattern that dictates the separation of read and write flows
● 1997: Bertrand Meyer first wrote about command query separation "Object Oriented Software
Construction”
● 2006: Greg Young came up with “CQRS”
○ Definition: “Uses a different model to update information than the model you use to read
information”
○ Opinion: You do not need two models! You only need one write model (source of truth).
Query just loads a projection from the data persistence layer (DB) through a repository.
● Usually met on enterprise world
● Stands for Command Query Responsibility Segregation
CQRS: Why I should use it?
● Performant read/write ops
● Infrastructure separation
● Scalability
● Enforce ground rules easier
● Testability
● Easier scaffolding around it
● Ideal when having multiple representations of the same data
● Cleaner and more Comprehensive API routes
● Fits amazingly well Event Sourcing
CQRS: Why I should avoid it?
● You will have to embrace eventual consistency
● Increased code complexity
● Increased complexity when synchronous requests
● Need experienced team or people with potential and appetite to read and learn
● Invest a little bit more on training, probably have to pay for some consultation
● Can cause some rework until you fully understand the patterns
What is eventual consistency
● The state of the object is not updated instantly in all read sources
● Eventually and if no errors, the object state will be updated
● Appears in everyday life
● Other types of consistency are:
○ strong
○ weak
Beans BaristaOrders
OrderPlacedEvent
OrderAcceptedEvent
OrderStartedEvent
OrderDeliveredEvent
OrderFinishedEvent
OrderBeansValidatedEvent
BeansFetchedEvent
CoffeeBrewStartedEvent
CoffeeBrewFinishedEvent
CoffeeBrewDeliveredEvent
ValidateBeansCommand
AcceptOrderCommand
StartOrderCommand
MakeCoffeeCommand
FinishOrderCommand
DeliverOrderCommand
PlaceOrderCommand
T
I
M
E
Explaining eventual consistency - Coffee order choreography
FetchBeansCommand
POST /order
response 202
GET /order/1
response 200
Delivered
GET /order/1
response 200
Accepted
GET /order/1
response 200
Started
GET /order/1
response 200
Finished
Is that all?
● Advanced layer decoupling
● REST “Alternatives”
● Never lose any data
● How to be synchronous
Should I use CQRS?
● Introduce it when a simple CRUD setup is not enough.
● Don’t go crazy! Take a stepped approach in order to feel comfortable.
● Avoid big refactorings or even worst rewritings.
● Complexity is increased but doable. You are getting a lot more in return.
● Keep in mind that increased complexity starts when you deal with distributed services and you have to deal with
eventual consistency.
Sources
● Domain-driven design Book by Eric Evans
● Implementing Domain-Driven Design Book by Vaughn Vernon
● From CQS to CQRS Article by Herberto Graca (https://herbertograca.com/2017/10/19/from-cqs-to-cqrs/)
● The software architecture chronicles Article by Herberto Graca
(https://herbertograca.com/2017/07/03/the-software-architecture-chronicles/amp)
● CQRS Article by Martin Fowler (https://martinfowler.com/bliki/CQRS.html)
● When, Why, and How to CQRS (https://www.youtube.com/watch?v=uTCKzPg0Uak)
● RabbitMq documentation (https://www.rabbitmq.com/tutorials/tutorial-six-python.html)
● Microsoft documentation (https://docs.microsoft.com/en-us/azure/architecture/patterns/cqrs)
● Hexagonal architecture demystified article by Zvonimir Spajic
(https://madewithlove.be/hexagonal-architecture-demystified/)
God it is over
Hopefully you made it until here
Thanks,
V

Contenu connexe

Tendances

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
 
Domain Driven Design - Building Blocks
Domain Driven Design - Building BlocksDomain Driven Design - Building Blocks
Domain Driven Design - Building BlocksMark Windholtz
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design Introductionwojtek_s
 
Pragmatic Architecture in .NET
Pragmatic Architecture in .NETPragmatic Architecture in .NET
Pragmatic Architecture in .NEThousecor
 
OO Design and Design Patterns in C++
OO Design and Design Patterns in C++ OO Design and Design Patterns in C++
OO Design and Design Patterns in C++ Ganesh Samarthyam
 
DDD Basics - Context mapping
DDD Basics - Context mappingDDD Basics - Context mapping
DDD Basics - Context mappingStijn Volders
 
Hexagonal architecture - message-oriented software design
Hexagonal architecture  - message-oriented software designHexagonal architecture  - message-oriented software design
Hexagonal architecture - message-oriented software designMatthias Noback
 
Domain-Driven Design: The "What" and the "Why"
Domain-Driven Design: The "What" and the "Why"Domain-Driven Design: The "What" and the "Why"
Domain-Driven Design: The "What" and the "Why"bincangteknologi
 
The Smells Of Bad Design
The Smells Of Bad DesignThe Smells Of Bad Design
The Smells Of Bad Designguest446c0
 
Lessons learned from building a commercial bot development platform
Lessons learned from building a commercial bot development platformLessons learned from building a commercial bot development platform
Lessons learned from building a commercial bot development platformJordi Cabot
 
Pragmatic Architecture for Agile Teams - GeeCON 2014
Pragmatic Architecture for Agile Teams - GeeCON 2014Pragmatic Architecture for Agile Teams - GeeCON 2014
Pragmatic Architecture for Agile Teams - GeeCON 2014Janne Sinivirta
 
Implementing DDD with C#
Implementing DDD with C#Implementing DDD with C#
Implementing DDD with C#Pascal Laurin
 
Domain-Driven Design (Artur Trosin Product Stream)
Domain-Driven Design (Artur Trosin Product Stream)Domain-Driven Design (Artur Trosin Product Stream)
Domain-Driven Design (Artur Trosin Product Stream)IT Arena
 
Zoo of domain-specific languages
Zoo of domain-specific languagesZoo of domain-specific languages
Zoo of domain-specific languagesMikhail Barash
 
Domain Driven Design Communication Techniques
Domain Driven Design Communication TechniquesDomain Driven Design Communication Techniques
Domain Driven Design Communication TechniquesMark Windholtz
 

Tendances (20)

SOAT Agile Day 2017 DDD
SOAT Agile Day 2017 DDDSOAT Agile Day 2017 DDD
SOAT Agile Day 2017 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
 
Domain Driven Design - Building Blocks
Domain Driven Design - Building BlocksDomain Driven Design - Building Blocks
Domain Driven Design - Building Blocks
 
DSLs: what, why, how
DSLs: what, why, howDSLs: what, why, how
DSLs: what, why, how
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design Introduction
 
Pragmatic Architecture in .NET
Pragmatic Architecture in .NETPragmatic Architecture in .NET
Pragmatic Architecture in .NET
 
OO Design and Design Patterns in C++
OO Design and Design Patterns in C++ OO Design and Design Patterns in C++
OO Design and Design Patterns in C++
 
DDD Basics - Context mapping
DDD Basics - Context mappingDDD Basics - Context mapping
DDD Basics - Context mapping
 
Hexagonal architecture - message-oriented software design
Hexagonal architecture  - message-oriented software designHexagonal architecture  - message-oriented software design
Hexagonal architecture - message-oriented software design
 
Domain-Driven Design: The "What" and the "Why"
Domain-Driven Design: The "What" and the "Why"Domain-Driven Design: The "What" and the "Why"
Domain-Driven Design: The "What" and the "Why"
 
SitFRA - No Comment?
SitFRA - No Comment?SitFRA - No Comment?
SitFRA - No Comment?
 
The Smells Of Bad Design
The Smells Of Bad DesignThe Smells Of Bad Design
The Smells Of Bad Design
 
Lessons learned from building a commercial bot development platform
Lessons learned from building a commercial bot development platformLessons learned from building a commercial bot development platform
Lessons learned from building a commercial bot development platform
 
Pragmatic Architecture for Agile Teams - GeeCON 2014
Pragmatic Architecture for Agile Teams - GeeCON 2014Pragmatic Architecture for Agile Teams - GeeCON 2014
Pragmatic Architecture for Agile Teams - GeeCON 2014
 
Implementing DDD with C#
Implementing DDD with C#Implementing DDD with C#
Implementing DDD with C#
 
Domain-Driven Design (Artur Trosin Product Stream)
Domain-Driven Design (Artur Trosin Product Stream)Domain-Driven Design (Artur Trosin Product Stream)
Domain-Driven Design (Artur Trosin Product Stream)
 
Patterns for distributed systems
Patterns for distributed systemsPatterns for distributed systems
Patterns for distributed systems
 
Zoo of domain-specific languages
Zoo of domain-specific languagesZoo of domain-specific languages
Zoo of domain-specific languages
 
Domain Driven Design Communication Techniques
Domain Driven Design Communication TechniquesDomain Driven Design Communication Techniques
Domain Driven Design Communication Techniques
 
Language Workbenches
Language WorkbenchesLanguage Workbenches
Language Workbenches
 

Similaire à A CQRS Journey

CQRS recipes or how to cook your architecture
CQRS recipes or how to cook your architectureCQRS recipes or how to cook your architecture
CQRS recipes or how to cook your architectureThomas Jaskula
 
JavaScript for Enterprise Applications
JavaScript for Enterprise ApplicationsJavaScript for Enterprise Applications
JavaScript for Enterprise ApplicationsPiyush Katariya
 
A Separation of Concerns: Clean Architecture on Android
A Separation of Concerns: Clean Architecture on AndroidA Separation of Concerns: Clean Architecture on Android
A Separation of Concerns: Clean Architecture on AndroidOutware Mobile
 
Deep Dive into the Idea of Software Architecture
Deep Dive into the Idea of Software ArchitectureDeep Dive into the Idea of Software Architecture
Deep Dive into the Idea of Software ArchitectureMatthew Clarke
 
Microservices as an evolutionary architecture: lessons learned
Microservices as an evolutionary architecture: lessons learnedMicroservices as an evolutionary architecture: lessons learned
Microservices as an evolutionary architecture: lessons learnedLuram Archanjo
 
Advanced web application architecture - Talk
Advanced web application architecture - TalkAdvanced web application architecture - Talk
Advanced web application architecture - TalkMatthias Noback
 
Fighting legacy with hexagonal architecture and frameworkless php
Fighting legacy with hexagonal architecture and frameworkless phpFighting legacy with hexagonal architecture and frameworkless php
Fighting legacy with hexagonal architecture and frameworkless phpFabio Pellegrini
 
Single page application
Single page applicationSingle page application
Single page applicationArthur Fung
 
IT for HR professionals
IT for HR professionalsIT for HR professionals
IT for HR professionalsMiguel Pinto
 
The working architecture of NodeJS applications, Виктор Турский
The working architecture of NodeJS applications, Виктор ТурскийThe working architecture of NodeJS applications, Виктор Турский
The working architecture of NodeJS applications, Виктор ТурскийSigma Software
 
The working architecture of node js applications open tech week javascript ...
The working architecture of node js applications   open tech week javascript ...The working architecture of node js applications   open tech week javascript ...
The working architecture of node js applications open tech week javascript ...Viktor Turskyi
 
Architecting for Change: An Agile Approach
Architecting for Change: An Agile ApproachArchitecting for Change: An Agile Approach
Architecting for Change: An Agile ApproachBen Stopford
 
Evolving compositional user interfaces
Evolving compositional user interfacesEvolving compositional user interfaces
Evolving compositional user interfacesAsbjørn Ulsberg
 
Ncrafts.io - Refactor your software architecture
Ncrafts.io - Refactor your software architectureNcrafts.io - Refactor your software architecture
Ncrafts.io - Refactor your software architectureJulien Lavigne du Cadet
 
Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"Fwdays
 
Couch DB/PouchDB approach for hybrid mobile applications
Couch DB/PouchDB approach for hybrid mobile applicationsCouch DB/PouchDB approach for hybrid mobile applications
Couch DB/PouchDB approach for hybrid mobile applicationsIhor Malytskyi
 
Designing and Implementing Information Systems with Event Modeling, Bobby Cal...
Designing and Implementing Information Systems with Event Modeling, Bobby Cal...Designing and Implementing Information Systems with Event Modeling, Bobby Cal...
Designing and Implementing Information Systems with Event Modeling, Bobby Cal...confluent
 

Similaire à A CQRS Journey (20)

CQRS recipes or how to cook your architecture
CQRS recipes or how to cook your architectureCQRS recipes or how to cook your architecture
CQRS recipes or how to cook your architecture
 
JavaScript for Enterprise Applications
JavaScript for Enterprise ApplicationsJavaScript for Enterprise Applications
JavaScript for Enterprise Applications
 
A Separation of Concerns: Clean Architecture on Android
A Separation of Concerns: Clean Architecture on AndroidA Separation of Concerns: Clean Architecture on Android
A Separation of Concerns: Clean Architecture on Android
 
Deep Dive into the Idea of Software Architecture
Deep Dive into the Idea of Software ArchitectureDeep Dive into the Idea of Software Architecture
Deep Dive into the Idea of Software Architecture
 
Microservices as an evolutionary architecture: lessons learned
Microservices as an evolutionary architecture: lessons learnedMicroservices as an evolutionary architecture: lessons learned
Microservices as an evolutionary architecture: lessons learned
 
Advanced web application architecture - Talk
Advanced web application architecture - TalkAdvanced web application architecture - Talk
Advanced web application architecture - Talk
 
Introduction to CQRS
Introduction to CQRSIntroduction to CQRS
Introduction to CQRS
 
Fighting legacy with hexagonal architecture and frameworkless php
Fighting legacy with hexagonal architecture and frameworkless phpFighting legacy with hexagonal architecture and frameworkless php
Fighting legacy with hexagonal architecture and frameworkless php
 
Single page application
Single page applicationSingle page application
Single page application
 
IT for HR professionals
IT for HR professionalsIT for HR professionals
IT for HR professionals
 
The working architecture of NodeJS applications, Виктор Турский
The working architecture of NodeJS applications, Виктор ТурскийThe working architecture of NodeJS applications, Виктор Турский
The working architecture of NodeJS applications, Виктор Турский
 
The working architecture of node js applications open tech week javascript ...
The working architecture of node js applications   open tech week javascript ...The working architecture of node js applications   open tech week javascript ...
The working architecture of node js applications open tech week javascript ...
 
Architecting for Change: An Agile Approach
Architecting for Change: An Agile ApproachArchitecting for Change: An Agile Approach
Architecting for Change: An Agile Approach
 
Evolutionary Design Solid
Evolutionary Design SolidEvolutionary Design Solid
Evolutionary Design Solid
 
Evolving compositional user interfaces
Evolving compositional user interfacesEvolving compositional user interfaces
Evolving compositional user interfaces
 
Ncrafts.io - Refactor your software architecture
Ncrafts.io - Refactor your software architectureNcrafts.io - Refactor your software architecture
Ncrafts.io - Refactor your software architecture
 
Cloud to Edge
Cloud to EdgeCloud to Edge
Cloud to Edge
 
Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"
 
Couch DB/PouchDB approach for hybrid mobile applications
Couch DB/PouchDB approach for hybrid mobile applicationsCouch DB/PouchDB approach for hybrid mobile applications
Couch DB/PouchDB approach for hybrid mobile applications
 
Designing and Implementing Information Systems with Event Modeling, Bobby Cal...
Designing and Implementing Information Systems with Event Modeling, Bobby Cal...Designing and Implementing Information Systems with Event Modeling, Bobby Cal...
Designing and Implementing Information Systems with Event Modeling, Bobby Cal...
 

Dernier

CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
How To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROHow To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROmotivationalword821
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 

Dernier (20)

CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
How To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROHow To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTRO
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 

A CQRS Journey

  • 1. A CQRS journey An introduction to Hexagonal Software Architectural Patterns, DDD & CQRS
  • 2.
  • 3. Who are we? Thanos Nokas Software Engineer Human Factor Thanos Korakas Web Developer Human Factor Sotiris Gkanouris Engineering Manager MessageBird Chrysovalantis Koutsoumpos Software Engineer
  • 4. Special thanks* Alberto Perego George Tsiatzios Sebastiaan Schinkel * alphabetically
  • 5. Where are we? SocialNerds Amsterdam branch Greek Digital Community (slack workspace)
  • 6. Disclaimer This presentation targets a broader audience and means to be seniority/experience agnostic. Its aim is to make a simple introduction to complex architectures providing with enough information to get started with them. Many structures, elements and steps are stripped in favour of simplicity. It is build with a step-by-step approach, in a way that everyone can follow.
  • 7. Software Architecture ● Fundamental structural choices ● Elements inside those structures ● Properties of the elements ● Responsibility of each element ● Relations between elements ● Constraints between structures and elements “The way that we are organizing our project’s structure and establishing communication between its elements”
  • 8. Architectural Patterns ● Reusable solution to a commonly occurring problem ● With focus on ○ performance ○ code quality ○ code reusability ○ infrastructure limitations, ○ high availability ○ minimization of a business risk ○ security ● Similar with (code) design patterns but with a broader scope “An already proven set of predefined structural, relation and constraint choices”
  • 9. Software architecture chronicles ● 50s: Non structured programming ● 60s: Structured programming ○ Tier 1 ● 1979: Procedural / Functional programming ○ Model View Controller (MVC) ● 80s: Object oriented programming ○ Tier 2 ● 1997: Web services, ESB ● 2003: Domain Driven Design (DDD) ● 2005: Hexagonal (AKA Ports & Adapters) ● 2006: Command Query Responsibility Segregation (CQRS), Event Sourcing ● 2008: Onion ● 2009: Microservices ● 2012: Clean A software project may use a combination of more than one architectural patterns
  • 10.
  • 12. Ports, adapters & adaptees ● A target is an object that we want to ● communicate with ● A port is an entry point. It defines a set of functions. ● An adapter is a bridge between the application and the service that is needed by the application. It fits a specific port. ● An adaptee the element that uses an adapter to communicate with a port. ● Think of your phone charger ○ Your phone is the Adaptee ○ The USB Adapter is the ...Adapter ○ The socket is the Target and it’s facade is Port GoF - Adapter Pattern
  • 13. use case use case Ports & Adapters Message Broker Adapter Persistence Adapter Adapter Adaptee HTTP use case Port Adaptee Adaptee Adaptee Adapter Adapter Adapter Port inside application and business logic outside Infrastructure outside UI HTTP Adapter CLI Adapter > CLI DB Message Broker UI & Infrastructure abstractions Port use case Port
  • 14. 2008 - Jeffrey Palermo inside application and business logic outside UI and Infrastructure outside UI and Infrastructure
  • 15. Onion architecture Domain Model Application Services UI / Infrastructure 2008 - Jeffrey Palermo Domain Services Dependency goes inwards Outer layers depend on inner layers Inner layers do not know about outer layers
  • 16. Domain, Application, API, UI and Infrastructure ● Domain Model Layer — Contains all business logic, the Entities, Events and any other object type that contains Business Logic ● Application Services Layer — Orchestrates Domain objects to perform tasks required by the end users ● User Interface Layer — Displays some data to end users and where end users interact with the system ● Infrastructure Layer — Technical capabilities that support the layers above, e.g. persistence or messaging
  • 17. Domain Application can not communicate can communicate UI / Infrastructure
  • 18. Domain Application UI / Infrastructure can not communicate can communicate
  • 19. Domain Application UI / Infrastructure can not communicate can communicate
  • 20. Domain Model Application Services UI / Infrastructure Domain Services Onion, a superset of Hexagonal The evolution of Ports & Adapters DB Message Broker HTTP > CLI
  • 21. Driving / Driven Adapters Message Broker Adapter Persistence Adapter Secondary/ Driven Port Port Port PortPort Primary / Driving Adapter Secondary/ Driven Adapter Domain Application UI / Infrastructure Webport CLIport Messagingport Persistenceport HTTP > CLI DB Message Broker CLI Adapter HTTPAdapter Primary / Driving Port
  • 24. (via the same) Application Application Driven Adapter (Infrastructure) DB Driving Adapter (UI) The separation of read and write flows one way Write flow Two way Read flow Write Domain GUI Read Domain
  • 25. What is CQRS ● An architectural pattern that dictates the separation of read and write flows ● 1997: Bertrand Meyer first wrote about command query separation "Object Oriented Software Construction” ● 2006: Greg Young came up with “CQRS” ○ Definition: “Uses a different model to update information than the model you use to read information” ○ Opinion: You do not need two models! You only need one write model (source of truth). Query just loads a projection from the data persistence layer (DB) through a repository. ● Usually met on enterprise world ● Stands for Command Query Responsibility Segregation
  • 26. CQRS: Why I should use it? ● Performant read/write ops ● Infrastructure separation ● Scalability ● Enforce ground rules easier ● Testability ● Easier scaffolding around it ● Ideal when having multiple representations of the same data ● Cleaner and more Comprehensive API routes ● Fits amazingly well Event Sourcing
  • 27. CQRS: Why I should avoid it? ● You will have to embrace eventual consistency ● Increased code complexity ● Increased complexity when synchronous requests ● Need experienced team or people with potential and appetite to read and learn ● Invest a little bit more on training, probably have to pay for some consultation ● Can cause some rework until you fully understand the patterns
  • 28. What is eventual consistency ● The state of the object is not updated instantly in all read sources ● Eventually and if no errors, the object state will be updated ● Appears in everyday life ● Other types of consistency are: ○ strong ○ weak
  • 30. Is that all? ● Advanced layer decoupling ● REST “Alternatives” ● Never lose any data ● How to be synchronous
  • 31. Should I use CQRS? ● Introduce it when a simple CRUD setup is not enough. ● Don’t go crazy! Take a stepped approach in order to feel comfortable. ● Avoid big refactorings or even worst rewritings. ● Complexity is increased but doable. You are getting a lot more in return. ● Keep in mind that increased complexity starts when you deal with distributed services and you have to deal with eventual consistency.
  • 32. Sources ● Domain-driven design Book by Eric Evans ● Implementing Domain-Driven Design Book by Vaughn Vernon ● From CQS to CQRS Article by Herberto Graca (https://herbertograca.com/2017/10/19/from-cqs-to-cqrs/) ● The software architecture chronicles Article by Herberto Graca (https://herbertograca.com/2017/07/03/the-software-architecture-chronicles/amp) ● CQRS Article by Martin Fowler (https://martinfowler.com/bliki/CQRS.html) ● When, Why, and How to CQRS (https://www.youtube.com/watch?v=uTCKzPg0Uak) ● RabbitMq documentation (https://www.rabbitmq.com/tutorials/tutorial-six-python.html) ● Microsoft documentation (https://docs.microsoft.com/en-us/azure/architecture/patterns/cqrs) ● Hexagonal architecture demystified article by Zvonimir Spajic (https://madewithlove.be/hexagonal-architecture-demystified/)
  • 33. God it is over Hopefully you made it until here Thanks, V