SlideShare une entreprise Scribd logo
1  sur  42
Télécharger pour lire hors ligne
From legacy to DDD
@andrzejkrzywda
Arkency
Did you write any
code today?
Was it good code?
Are you proud of it?
Why?
(do you think that surgeons are proud of their work?)
What is legacy code?
Ruby is much more unified here than PHP
Any Rails code is legacy code
Legacy
• Frameworks
• monolithic
• no architecture
• no tests
DDD
Strategic vs Tactical
DDD
Tactical DDD
• entity
• value objects
• aggregate
• domain event
• services
• repositories
• factory
DDD-lite
• app service
• domain service
• load aggregate from the repo
• do sth cool
• may use some value objects
• may trigger some domain events
• save aggregate (repo)
Strategic DDD
• bounded contexts
• context map
http://martinfowler.com/bliki/BoundedContext.html
Software House
management tool
as microservices
partially available
different persistence
data duplication
Context Map
HR Project Management Finances
Invoicing
CRUD
DDD-lite
external SaaS
Communication
developer
project
client
How to get there from
legacy?
BTW, There’s no such thing as the ultimate DDD codebase
Draw the Context Map
the only thing to remember from this talk
Ongoing process
No time for 2-months rewrites
Peopleware
the human factor
http://andrzejonsoftware.blogspot.com/2014/01/refactoring-human-factor.html
Escape from the
CRUD verbs
Talk more to the business people
Test coverage
#noregressions
when you’re a client you don’t like them too
Mutation testing
is the real test coverage!
http://blog.arkency.com/2015/04/why-i-want-to-introduce-mutation-testing-to-the-rails-event-store-gem/
http://blog.arkency.com/2015/06/how-good-are-your-ruby-tests-testing-your-tests-with-mutant/
mutation testing
php - humbug
https://github.com/padraic/humbug
Test units, not classes!
http://andrzejonsoftware.blogspot.com/2015/02/tdding-unit-not-class.html
http://andrzejonsoftware.blogspot.com/2014/04/tdd-and-rails-what-makes-good-unit.html
http://blog.arkency.com/2014/09/unit-tests-vs-class-tests/
Escape from the
framework ASAP
http://blog.arkency.com/2015/03/extract-a-service-object-in-any-framework/
Call application services from the framework
Active Record doesn’t
make your code happy
AR is not DDD-lite-friendly
Data Mapper is better here
Don’t just pass the
params/hash everywhere
http://andrzejonsoftware.blogspot.com/2011/12/args-opts-params.html
Wrap your legacy
contexts with the
application services layer
Use events to
communicate between
bounded contexts
rails_event_store
Separate reads/writes
at the services layer
CQRS
Eliminate querying
from BC to another
Push the data!
Keep the Bounded Contexts
in-sync by publishing all the
important events
Easier testing when no
dependency on other
system
Read models
Denormalized data
Treat your frontend as a
separate Bounded
Context
When in doubt, think
in aggregates
Event sourcing
build your aggregates from events
audit log for free
(no, it’s not slow, but thanks for asking)
Distributed
transactions are tricky
Easier setup of the
project when it’s a smaller
piece
Useful when you’re maintaining many projects and need to bugfix them from time to time
https://laracasts.com/discuss/channels/general-discussion/folder-and-namespace-structure-with-ddd/replies/17753
Legacy -> DDD books
• red book, Vaughn Vernon
• blue book, Eric Evans
• Refactoring, Fowler
• Legacy code, Feathers
THANKS!
(go draw your context maps now)

Contenu connexe

Tendances

Gradle(the innovation continues)
Gradle(the innovation continues)Gradle(the innovation continues)
Gradle(the innovation continues)
Sejong Park
 

Tendances (20)

THE PLEASURES OF ON-PREM, TOMER GABEL
THE PLEASURES OF ON-PREM, TOMER GABELTHE PLEASURES OF ON-PREM, TOMER GABEL
THE PLEASURES OF ON-PREM, TOMER GABEL
 
Roadmap to Enterprise Quality
Roadmap to Enterprise QualityRoadmap to Enterprise Quality
Roadmap to Enterprise Quality
 
DocOps — The Analytical Window to Your Customer’s Experience with Wade Clements
DocOps — The Analytical Window to Your Customer’s Experience with Wade ClementsDocOps — The Analytical Window to Your Customer’s Experience with Wade Clements
DocOps — The Analytical Window to Your Customer’s Experience with Wade Clements
 
Building Scalable Micro-services with Nodejs
Building Scalable Micro-services with NodejsBuilding Scalable Micro-services with Nodejs
Building Scalable Micro-services with Nodejs
 
DocOps: Documentation at the Speed of Agile
DocOps: Documentation at the Speed of AgileDocOps: Documentation at the Speed of Agile
DocOps: Documentation at the Speed of Agile
 
Aws, play! couch db scaling soa in the cloud
Aws, play! couch db  scaling soa in the cloudAws, play! couch db  scaling soa in the cloud
Aws, play! couch db scaling soa in the cloud
 
Scala from the Trenches - Java One 2016
Scala from the Trenches - Java One 2016Scala from the Trenches - Java One 2016
Scala from the Trenches - Java One 2016
 
Solving trust issues at scale - Omer Levi Hevroni
Solving trust issues at scale - Omer Levi HevroniSolving trust issues at scale - Omer Levi Hevroni
Solving trust issues at scale - Omer Levi Hevroni
 
Overview of modern software ecosystem for big data analysis
Overview of modern software ecosystem for big data analysisOverview of modern software ecosystem for big data analysis
Overview of modern software ecosystem for big data analysis
 
Building the Web with Gradle
Building the Web with GradleBuilding the Web with Gradle
Building the Web with Gradle
 
End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013
 
Angular vs React - Devoxx BE 2017
Angular vs React - Devoxx BE 2017Angular vs React - Devoxx BE 2017
Angular vs React - Devoxx BE 2017
 
SGCE 2015 REST APIs
SGCE 2015 REST APIsSGCE 2015 REST APIs
SGCE 2015 REST APIs
 
Structuring for Content Reuse with MadCap Doc-To-Help
Structuring for Content Reuse with MadCap Doc-To-HelpStructuring for Content Reuse with MadCap Doc-To-Help
Structuring for Content Reuse with MadCap Doc-To-Help
 
Strong Consistency in Databases. What does it actually guarantee? - Andy Goo...
 Strong Consistency in Databases. What does it actually guarantee? - Andy Goo... Strong Consistency in Databases. What does it actually guarantee? - Andy Goo...
Strong Consistency in Databases. What does it actually guarantee? - Andy Goo...
 
Microservices Architecture: Nirvana or Nightmare
Microservices Architecture: Nirvana or NightmareMicroservices Architecture: Nirvana or Nightmare
Microservices Architecture: Nirvana or Nightmare
 
Angular4 kickstart
Angular4 kickstartAngular4 kickstart
Angular4 kickstart
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Let's Graph
Let's GraphLet's Graph
Let's Graph
 
Gradle(the innovation continues)
Gradle(the innovation continues)Gradle(the innovation continues)
Gradle(the innovation continues)
 

En vedette

Domain driven design in a nutshell
Domain driven design in a nutshellDomain driven design in a nutshell
Domain driven design in a nutshell
Toni Esteves
 
Simplifying your design with higher-order functions
Simplifying your design with higher-order functionsSimplifying your design with higher-order functions
Simplifying your design with higher-order functions
Samir Talwar
 
Parallel Complex Event Processing
Parallel Complex Event ProcessingParallel Complex Event Processing
Parallel Complex Event Processing
Karol Grzegorczyk
 

En vedette (20)

Domain-driven design - tactical patterns
Domain-driven design - tactical patternsDomain-driven design - tactical patterns
Domain-driven design - tactical patterns
 
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 101
Domain Driven Design 101Domain Driven Design 101
Domain Driven Design 101
 
Domain Driven Design in an Agile World
Domain Driven Design in an Agile WorldDomain Driven Design in an Agile World
Domain Driven Design in an Agile World
 
DDD In Agile
DDD In Agile   DDD In Agile
DDD In Agile
 
Domain-Driven Design workshops
Domain-Driven Design workshopsDomain-Driven Design workshops
Domain-Driven Design workshops
 
Domain-Driven Design und Hexagonale Architektur
Domain-Driven Design und Hexagonale ArchitekturDomain-Driven Design und Hexagonale Architektur
Domain-Driven Design und Hexagonale Architektur
 
Common ddd pitfalls
Common ddd pitfallsCommon ddd pitfalls
Common ddd pitfalls
 
Domain driven design
Domain driven designDomain driven design
Domain driven design
 
What is DDD and how could it help you
What is DDD and how could it help youWhat is DDD and how could it help you
What is DDD and how could it help you
 
Ddd reboot (english version)
Ddd reboot (english version)Ddd reboot (english version)
Ddd reboot (english version)
 
Domain driven design in a nutshell
Domain driven design in a nutshellDomain driven design in a nutshell
Domain driven design in a nutshell
 
Simplifying your design with higher-order functions
Simplifying your design with higher-order functionsSimplifying your design with higher-order functions
Simplifying your design with higher-order functions
 
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
 
Domain Driven Design Quickly
Domain Driven Design QuicklyDomain Driven Design Quickly
Domain Driven Design Quickly
 
Introduction to-ddd
Introduction to-dddIntroduction to-ddd
Introduction to-ddd
 
Our way to microservices
Our way to microservicesOur way to microservices
Our way to microservices
 
Modelling a complex domain with Domain-Driven Design
Modelling a complex domain with Domain-Driven DesignModelling a complex domain with Domain-Driven Design
Modelling a complex domain with Domain-Driven Design
 
I T.A.K.E. talk: "When DDD meets FP, good things happen"
I T.A.K.E. talk: "When DDD meets FP, good things happen"I T.A.K.E. talk: "When DDD meets FP, good things happen"
I T.A.K.E. talk: "When DDD meets FP, good things happen"
 
Parallel Complex Event Processing
Parallel Complex Event ProcessingParallel Complex Event Processing
Parallel Complex Event Processing
 

Similaire à From legacy to DDD

Similaire à From legacy to DDD (20)

From legacy to DDD (slides for the screencast)
From legacy to DDD (slides for the screencast)From legacy to DDD (slides for the screencast)
From legacy to DDD (slides for the screencast)
 
Better and Faster: A Journey Toward Clean Code and Enjoyment
Better and Faster: A Journey Toward Clean Code and EnjoymentBetter and Faster: A Journey Toward Clean Code and Enjoyment
Better and Faster: A Journey Toward Clean Code and Enjoyment
 
So Many Frameworks, So Little Time
So Many Frameworks, So Little TimeSo Many Frameworks, So Little Time
So Many Frameworks, So Little Time
 
Write Generic Code with the Tooling API
Write Generic Code with the Tooling APIWrite Generic Code with the Tooling API
Write Generic Code with the Tooling API
 
Code stock
Code stockCode stock
Code stock
 
Deploying Web Apps with PaaS and Docker Tools
Deploying Web Apps with PaaS and Docker ToolsDeploying Web Apps with PaaS and Docker Tools
Deploying Web Apps with PaaS and Docker Tools
 
Viridians on Rails
Viridians on RailsViridians on Rails
Viridians on Rails
 
Serverless Computing with Azure Functions and Xamarin
Serverless Computing with Azure Functions and XamarinServerless Computing with Azure Functions and Xamarin
Serverless Computing with Azure Functions and Xamarin
 
Measure and increase developer productivity with help of Severless by Kazulki...
Measure and increase developer productivity with help of Severless by Kazulki...Measure and increase developer productivity with help of Severless by Kazulki...
Measure and increase developer productivity with help of Severless by Kazulki...
 
Refactoring to Testable Code
Refactoring to Testable CodeRefactoring to Testable Code
Refactoring to Testable Code
 
APIdays Paris 2019 - API Descriptions as Product Code by Phil Sturgeon, Stopl...
APIdays Paris 2019 - API Descriptions as Product Code by Phil Sturgeon, Stopl...APIdays Paris 2019 - API Descriptions as Product Code by Phil Sturgeon, Stopl...
APIdays Paris 2019 - API Descriptions as Product Code by Phil Sturgeon, Stopl...
 
Morden F2E Education - Think of Progressive Web Apps
Morden F2E Education - Think of Progressive Web AppsMorden F2E Education - Think of Progressive Web Apps
Morden F2E Education - Think of Progressive Web Apps
 
Spring Boot & Spring Cloud on PAS- Nate Schutta (1/2)
Spring Boot & Spring Cloud on PAS- Nate Schutta (1/2)Spring Boot & Spring Cloud on PAS- Nate Schutta (1/2)
Spring Boot & Spring Cloud on PAS- Nate Schutta (1/2)
 
Developing cloud serverless components in Python: DDD Perspective
Developing cloud serverless components in Python: DDD PerspectiveDeveloping cloud serverless components in Python: DDD Perspective
Developing cloud serverless components in Python: DDD Perspective
 
Introduction to real time big data with Apache Spark
Introduction to real time big data with Apache SparkIntroduction to real time big data with Apache Spark
Introduction to real time big data with Apache Spark
 
Serverless in production, an experience report (Going Serverless)
Serverless in production, an experience report (Going Serverless)Serverless in production, an experience report (Going Serverless)
Serverless in production, an experience report (Going Serverless)
 
Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"
 
[2011-17-C-4] Heroku & database.com
[2011-17-C-4] Heroku & database.com[2011-17-C-4] Heroku & database.com
[2011-17-C-4] Heroku & database.com
 
Angular (v2 and up) - Morning to understand - Linagora
Angular (v2 and up) - Morning to understand - LinagoraAngular (v2 and up) - Morning to understand - Linagora
Angular (v2 and up) - Morning to understand - Linagora
 
Challenges of angular in production (Tasos Bekos) - GreeceJS #17
Challenges of angular in production (Tasos Bekos) - GreeceJS #17Challenges of angular in production (Tasos Bekos) - GreeceJS #17
Challenges of angular in production (Tasos Bekos) - GreeceJS #17
 

Plus de Andrzej Krzywda

[Polish] Praca zdalna, praca asynchroniczna
[Polish] Praca zdalna, praca asynchroniczna[Polish] Praca zdalna, praca asynchroniczna
[Polish] Praca zdalna, praca asynchroniczna
Andrzej Krzywda
 

Plus de Andrzej Krzywda (19)

[PL] PRUG Luty 2022 - Service objecty to za mało - jak żyć z Railsami?
[PL] PRUG Luty 2022 - Service objecty to za mało - jak żyć z Railsami?[PL] PRUG Luty 2022 - Service objecty to za mało - jak żyć z Railsami?
[PL] PRUG Luty 2022 - Service objecty to za mało - jak żyć z Railsami?
 
[PL] Service objecty to za mało - jak żyć z Railsami?
[PL] Service objecty to za mało - jak żyć z Railsami?[PL] Service objecty to za mało - jak żyć z Railsami?
[PL] Service objecty to za mało - jak żyć z Railsami?
 
Audit log with event sourcing
Audit log with event sourcingAudit log with event sourcing
Audit log with event sourcing
 
Event driven without microservices
Event driven without microservicesEvent driven without microservices
Event driven without microservices
 
From legacy to DDD - 5 starting steps
From legacy to DDD - 5 starting stepsFrom legacy to DDD - 5 starting steps
From legacy to DDD - 5 starting steps
 
Slack protips from Arkency
Slack protips from ArkencySlack protips from Arkency
Slack protips from Arkency
 
DCI - the architecture from the future
DCI - the architecture from the futureDCI - the architecture from the future
DCI - the architecture from the future
 
Refactoring Rails applications with RubyMine
Refactoring Rails applications with RubyMineRefactoring Rails applications with RubyMine
Refactoring Rails applications with RubyMine
 
Beyond The Rails Way
Beyond The Rails WayBeyond The Rails Way
Beyond The Rails Way
 
Service objects in Rails tests - factory_girl replacement
Service objects in Rails tests - factory_girl replacementService objects in Rails tests - factory_girl replacement
Service objects in Rails tests - factory_girl replacement
 
Developer oriented
Developer orientedDeveloper oriented
Developer oriented
 
Can you TDD Rails?
Can you TDD Rails?Can you TDD Rails?
Can you TDD Rails?
 
A programmer or a business consultant?
A programmer or a business consultant?A programmer or a business consultant?
A programmer or a business consultant?
 
Rails refactoring call for help
Rails refactoring call for helpRails refactoring call for help
Rails refactoring call for help
 
[Polish] Praca zdalna, praca asynchroniczna
[Polish] Praca zdalna, praca asynchroniczna[Polish] Praca zdalna, praca asynchroniczna
[Polish] Praca zdalna, praca asynchroniczna
 
Use cases in the code with AOP
Use cases in the code with AOPUse cases in the code with AOP
Use cases in the code with AOP
 
Single Page Applications with CoffeeScript [Polish]
Single Page Applications with CoffeeScript [Polish]Single Page Applications with CoffeeScript [Polish]
Single Page Applications with CoffeeScript [Polish]
 
Madeleine on Rails
Madeleine on RailsMadeleine on Rails
Madeleine on Rails
 
TDD with Rails
TDD with RailsTDD with Rails
TDD with Rails
 

Dernier

Dernier (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

From legacy to DDD