SlideShare une entreprise Scribd logo
1  sur  86
Télécharger pour lire hors ligne
D R S T R A N G L E R 

& M R H Y P E
S T R A N G L E R PAT T E R N I N P R A C T I C E
Michał Kurzeja
CTO @ Accesto
TW: @michalKurzeja
michal@accesto.com
T H I S TA L K S I S A B O U T
• Where legacy comes from?
• Why it is worth to get rid of legacy…
• … and how to make it properly?
• How not to hurt yourself
• Examples
T H I S TA L K I S N O T A B O U T
• How to test
• How to refactor classes/methods
• Silver bullet step-by-step approach
Bad practices
„Mr Hype”
Good practices

„Dr Strangler”
L E G A C Y C O D E
L E G A C Y ! = I N H E R I T E D C O D E
E X P E C TAT I O N S
R E A L I T Y
Q U A L I T Y D E C R E A S E S I N T I M E
- L A C K O F T H E „ B O Y S C O U T ” R U L E
0
17,5
35
52,5
70
2010 2011 2012 2013
R E S U LT S ? I S S U E S :
• Complicated code
• Harder to write tests
• Difficult deployment
• Reluctance of developers
• Hard to develop
H O W T O C O N V I N C E B U S I N E S S
• Slower development
• competitors might be faster
• increased costs
• HR issues: harder recruitment, more people leaving
• Lots of bugs, angry customers
• It might explode at any time ;)
2 0 1 2 , K N I G H T C A P I TA L G R O U P
$460 mln loss in 45 minutes
W H AT C A N W E D O ?
R E W R I T E F R O M S C R AT C H
F R O M 9 0 % T O 0 %
O F M A R K E T S H A R E
D E C L I N E O F N E T S C A P E
L O S T I T T O I N T E R N E T E X P L O R E R !
K E E P O N G O I N G
R E FA C T O R ?
Rewrite from scratchKeep on going
Refactor STRANGLE!
FUN
RISK
S T R A N G L E R PAT T E R N
G AT E WAY / FA C A D E
G AT E WAY - B U I L D I T L E A N
server {

listen 80;

server_name domain.com;



location /profile {

proxy_pass http://10.0.3.10:80;

}



location /news {

proxy_pass http://10.0.3.10:80;

}



proxy_pass http://10.0.3.20:80;

}
G AT E WAY - P O S S I B L E S O L U T I O N S
• API - Open Source
• Kong
• API - Paid
• AWS API Gateway
• WWW
• HaProxy
• Nginx/Apache/…
S TA R T W I T H C AT C H A L L
S H A R E D D ATA B A S E
D I S T R I B U T E D S H I T
S P L I T D ATA B A S E S
• Scheduled sync (cron)
• Events (required change in legacy)
• DB Triggers
• Transaction log (Binlog -> Kafka)
A P I
B O U N D A R I E S
ANTI-CORRUPTION LAYER
A C L
L E G A C Y I N A B O X
I N P R A C T I C E
L O N G T I M E A G O …
• Market leader
• Project started in 2010, we took over in 2016
• Customers: banks, political parties - no downtime
allowed ;)
N O F R O N T- C O N T R O L L E R
„ C U T E ” V E R S I O N I N G
„ M A G I C ” S T R U C T U R E
„ B U L L E T P R O O F ” C O N F I G
It was $_SERVER[SERVER_NAME];
„ R E A D A B L E ” C O D E
Generally….
S E V E R A L G R AY H A I R L AT E R
• Monorepo
• Apache as facade
• Anti-Corruption Layer -> API
• JSON Web Token
• Configuration by env variables
• 100% automated deployment (on Kubernetes)
• Business is very happy
• Programmers are still alive (and work for us)
M I S TA K E S 

W H AT C O U L D B E D O N E B E T T E R
F E AT U R E T O G G L E
J W T F R O M D AY 1 0
B E T T E R A C L
I S S U E S
P R O S
• Small risk, less stress, quick releases
• Instant effects
• Both business and developers happy
S E C O N D A P P R O A C H - A C L *
* M O D I F I E D A B I T
M O D E R N A C L L E G A C Y
https://github.com/VaughnVernon/IDDD_Samples/tree/master/iddd_collaboration/src/main/java/com/saasovation/
collaboration/port/adapter/service
M O D E R N A C L L E G A C Y
APIREPO
class Currency
{
private $isoCode;
private $default;
private $ratio;
}
M O D E R N - C U R R E N C Y M O D E L
interface CurrencyRepository
{
public function findAll();
public function getDefault();
public function find(string $isoCode);
public function save(Currency $currency);
}
M O D E R N - C U R R E N C Y R E P O S I T O RY
class Internal_CurrencyController extends Internal_Controller_InternalController
{
public function listcurrenciesAction()
{
$this->checkIp();
$this->getResponse()->setHeader('Content-type', 'application/json');
$mCurrency = new Default_Model_Currency();
/** @var Zend_Db_Table_Rowset $currencies */
$currencies = $mCurrency->fetchAll('status = "active"');
$this->getResponse()
->setBody(json_encode($currencies->toArray()))
->setHttpResponseCode(200);
}
}
L E G A C Y - C U R R E N C Y FA C A D E
interface CurrencyAdapter
{
public function findAll(): array;
}
A C L - C U R R E N C Y A P I I N T E R FA C E
class LegacyCurrencyAdapter implements CurrencyAdapter
{
public function findAll(): array
{
$response = $this->client->request('GET', 'listCurrencies');
$currencies = json_decode((string) $response->getBody(), true);
return array_map(function ($row) {
$currency = $this->currencyTranslator->createFromArray($row);
if ($exCurrency = $this->currRepo->find($currency->isoCode())) {
$currency->setRatio($exCurrency->getRatio());
$currency->setDefault($exCurrency->getDefault());
}
return $currency;
}, $currencies);
}
}
A C L - C U R R E N C Y A P I
class LegacyCurrencyTranslator implements CurrencyTranslator
{
public function createFromArray(array $data)
{
$default = filter_var($data['default'], FILTER_VALIDATE_BOOLEAN);
$ratio = filter_var($data['value'], FILTER_VALIDATE_FLOAT);
return new Currency($data['code'], $ratio, $default);
}
}
A C L - C U R R E N C Y T R A N S L AT O R
W H AT N O T T O D O
R O U T I N G I N L E G A C Y / M O D E R N
L A C K O F A N T I - C O R R U P T I O N L AY E R
P L A N F I R S T,
C O D E L AT E R
GETTING STARTED WITH DDD WHEN SURROUNDED BY
LEGACY SYSTEMS
E R I C E VA N S
W R I T E S O F T WA R E T H AT
I S E A S Y T O S T R A N G L E
Michał Kurzeja
CTO @ Accesto
@michalKurzeja
michal@accesto.com
Thanks!

Contenu connexe

Similaire à Strangler Pattern in practice @PHPers Day 2019

Architecting your IT career
Architecting your IT careerArchitecting your IT career
Architecting your IT careerJohn Mark Troyer
 
Reduce, Reuse, Refactor
Reduce, Reuse, RefactorReduce, Reuse, Refactor
Reduce, Reuse, Refactorcklosowski
 
Zend con 2016 - Asynchronous Prorgamming in PHP
Zend con 2016 - Asynchronous Prorgamming in PHPZend con 2016 - Asynchronous Prorgamming in PHP
Zend con 2016 - Asynchronous Prorgamming in PHPAdam Englander
 
SharePoint Saturday Redmond - Building solutions with the future in mind
SharePoint Saturday Redmond - Building solutions with the future in mindSharePoint Saturday Redmond - Building solutions with the future in mind
SharePoint Saturday Redmond - Building solutions with the future in mindChris Johnson
 
Cloud Identity Deployed
Cloud Identity DeployedCloud Identity Deployed
Cloud Identity DeployedPablo Valarezo
 
Introduction of the Agile Digital Enterprise Framework
Introduction of the Agile Digital Enterprise FrameworkIntroduction of the Agile Digital Enterprise Framework
Introduction of the Agile Digital Enterprise FrameworkPierre E. NEIS
 
Choosing the right database
Choosing the right databaseChoosing the right database
Choosing the right databaseDavid Simons
 
Angular server side rendering with NodeJS - In Pursuit Of Speed
Angular server side rendering with NodeJS - In Pursuit Of SpeedAngular server side rendering with NodeJS - In Pursuit Of Speed
Angular server side rendering with NodeJS - In Pursuit Of SpeedIlia Idakiev
 
Data Modelling at Scale
Data Modelling at ScaleData Modelling at Scale
Data Modelling at ScaleDavid Simons
 
From Content Strategy to Drupal Site Building - Connecting the dots
From Content Strategy to Drupal Site Building - Connecting the dotsFrom Content Strategy to Drupal Site Building - Connecting the dots
From Content Strategy to Drupal Site Building - Connecting the dotsRonald Ashri
 
From Content Strategy to Drupal Site Building - Connecting the Dots
From Content Strategy to Drupal Site Building - Connecting the DotsFrom Content Strategy to Drupal Site Building - Connecting the Dots
From Content Strategy to Drupal Site Building - Connecting the DotsRonald Ashri
 
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHPphp[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHPAdam Englander
 
Decoupled APIs through microservices
Decoupled APIs through microservicesDecoupled APIs through microservices
Decoupled APIs through microservicesDavid Simons
 
Reduce, Reuse, Refactor
Reduce, Reuse, RefactorReduce, Reuse, Refactor
Reduce, Reuse, Refactorcklosowski
 
React native first impression
React native first impressionReact native first impression
React native first impressionAlvaro Viebrantz
 
Creating Modern Metadata Systems [FutureStack16 NYC]
Creating Modern Metadata Systems [FutureStack16 NYC]Creating Modern Metadata Systems [FutureStack16 NYC]
Creating Modern Metadata Systems [FutureStack16 NYC]New Relic
 
The Blockchain: an Enterprise Play
The Blockchain: an Enterprise PlayThe Blockchain: an Enterprise Play
The Blockchain: an Enterprise PlayLisa Cheng
 

Similaire à Strangler Pattern in practice @PHPers Day 2019 (20)

Architecting your IT career
Architecting your IT careerArchitecting your IT career
Architecting your IT career
 
Reduce, Reuse, Refactor
Reduce, Reuse, RefactorReduce, Reuse, Refactor
Reduce, Reuse, Refactor
 
Zend con 2016 - Asynchronous Prorgamming in PHP
Zend con 2016 - Asynchronous Prorgamming in PHPZend con 2016 - Asynchronous Prorgamming in PHP
Zend con 2016 - Asynchronous Prorgamming in PHP
 
SharePoint Saturday Redmond - Building solutions with the future in mind
SharePoint Saturday Redmond - Building solutions with the future in mindSharePoint Saturday Redmond - Building solutions with the future in mind
SharePoint Saturday Redmond - Building solutions with the future in mind
 
Cloud Identity Deployed
Cloud Identity DeployedCloud Identity Deployed
Cloud Identity Deployed
 
Introduction of the Agile Digital Enterprise Framework
Introduction of the Agile Digital Enterprise FrameworkIntroduction of the Agile Digital Enterprise Framework
Introduction of the Agile Digital Enterprise Framework
 
Choosing the right database
Choosing the right databaseChoosing the right database
Choosing the right database
 
Angular server side rendering with NodeJS - In Pursuit Of Speed
Angular server side rendering with NodeJS - In Pursuit Of SpeedAngular server side rendering with NodeJS - In Pursuit Of Speed
Angular server side rendering with NodeJS - In Pursuit Of Speed
 
Data Modelling at Scale
Data Modelling at ScaleData Modelling at Scale
Data Modelling at Scale
 
From Content Strategy to Drupal Site Building - Connecting the dots
From Content Strategy to Drupal Site Building - Connecting the dotsFrom Content Strategy to Drupal Site Building - Connecting the dots
From Content Strategy to Drupal Site Building - Connecting the dots
 
From Content Strategy to Drupal Site Building - Connecting the Dots
From Content Strategy to Drupal Site Building - Connecting the DotsFrom Content Strategy to Drupal Site Building - Connecting the Dots
From Content Strategy to Drupal Site Building - Connecting the Dots
 
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHPphp[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
 
Decoupled APIs through microservices
Decoupled APIs through microservicesDecoupled APIs through microservices
Decoupled APIs through microservices
 
The Road to QA
The Road to QAThe Road to QA
The Road to QA
 
Content First in Action
Content First in ActionContent First in Action
Content First in Action
 
Reduce, Reuse, Refactor
Reduce, Reuse, RefactorReduce, Reuse, Refactor
Reduce, Reuse, Refactor
 
BoSUSA18 | Bob Moesta| The 5 Skills Of An Innovator
BoSUSA18 | Bob Moesta| The 5 Skills Of An InnovatorBoSUSA18 | Bob Moesta| The 5 Skills Of An Innovator
BoSUSA18 | Bob Moesta| The 5 Skills Of An Innovator
 
React native first impression
React native first impressionReact native first impression
React native first impression
 
Creating Modern Metadata Systems [FutureStack16 NYC]
Creating Modern Metadata Systems [FutureStack16 NYC]Creating Modern Metadata Systems [FutureStack16 NYC]
Creating Modern Metadata Systems [FutureStack16 NYC]
 
The Blockchain: an Enterprise Play
The Blockchain: an Enterprise PlayThe Blockchain: an Enterprise Play
The Blockchain: an Enterprise Play
 

Plus de Michał Kurzeja

Kolejkowanie w systemach multi-tenant - PHPCon 2023
Kolejkowanie w systemach multi-tenant - PHPCon 2023Kolejkowanie w systemach multi-tenant - PHPCon 2023
Kolejkowanie w systemach multi-tenant - PHPCon 2023Michał Kurzeja
 
Rozszerzalność Symfony - PHPCon 2023
Rozszerzalność Symfony - PHPCon 2023Rozszerzalność Symfony - PHPCon 2023
Rozszerzalność Symfony - PHPCon 2023Michał Kurzeja
 
Event-driven architecture, the easy way.pdf
Event-driven architecture, the easy way.pdfEvent-driven architecture, the easy way.pdf
Event-driven architecture, the easy way.pdfMichał Kurzeja
 
Rozszerzalność aplikacji Symfony
Rozszerzalność aplikacji SymfonyRozszerzalność aplikacji Symfony
Rozszerzalność aplikacji SymfonyMichał Kurzeja
 
Docker reverse proxy z użyciem Traefik
Docker reverse proxy z użyciem TraefikDocker reverse proxy z użyciem Traefik
Docker reverse proxy z użyciem TraefikMichał Kurzeja
 
Symfony messenger - PHPers Summit 2019
Symfony messenger - PHPers Summit 2019Symfony messenger - PHPers Summit 2019
Symfony messenger - PHPers Summit 2019Michał Kurzeja
 
Kubernetes - 0 do 1 - 4Developers Warszawa 2019
Kubernetes - 0 do 1 - 4Developers Warszawa 2019Kubernetes - 0 do 1 - 4Developers Warszawa 2019
Kubernetes - 0 do 1 - 4Developers Warszawa 2019Michał Kurzeja
 
Symfony2 - garść porad
Symfony2 - garść poradSymfony2 - garść porad
Symfony2 - garść poradMichał Kurzeja
 

Plus de Michał Kurzeja (11)

Kolejkowanie w systemach multi-tenant - PHPCon 2023
Kolejkowanie w systemach multi-tenant - PHPCon 2023Kolejkowanie w systemach multi-tenant - PHPCon 2023
Kolejkowanie w systemach multi-tenant - PHPCon 2023
 
Rozszerzalność Symfony - PHPCon 2023
Rozszerzalność Symfony - PHPCon 2023Rozszerzalność Symfony - PHPCon 2023
Rozszerzalność Symfony - PHPCon 2023
 
Event-driven architecture, the easy way.pdf
Event-driven architecture, the easy way.pdfEvent-driven architecture, the easy way.pdf
Event-driven architecture, the easy way.pdf
 
Rozszerzalność aplikacji Symfony
Rozszerzalność aplikacji SymfonyRozszerzalność aplikacji Symfony
Rozszerzalność aplikacji Symfony
 
Docker reverse proxy z użyciem Traefik
Docker reverse proxy z użyciem TraefikDocker reverse proxy z użyciem Traefik
Docker reverse proxy z użyciem Traefik
 
Symfony messenger - PHPers Summit 2019
Symfony messenger - PHPers Summit 2019Symfony messenger - PHPers Summit 2019
Symfony messenger - PHPers Summit 2019
 
Kubernetes - 0 do 1 - 4Developers Warszawa 2019
Kubernetes - 0 do 1 - 4Developers Warszawa 2019Kubernetes - 0 do 1 - 4Developers Warszawa 2019
Kubernetes - 0 do 1 - 4Developers Warszawa 2019
 
Serverless Architecture
Serverless ArchitectureServerless Architecture
Serverless Architecture
 
Docker workshop
Docker workshopDocker workshop
Docker workshop
 
Docker - introduction
Docker - introductionDocker - introduction
Docker - introduction
 
Symfony2 - garść porad
Symfony2 - garść poradSymfony2 - garść porad
Symfony2 - garść porad
 

Dernier

Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 

Dernier (20)

Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 

Strangler Pattern in practice @PHPers Day 2019

  • 1. D R S T R A N G L E R 
 & M R H Y P E S T R A N G L E R PAT T E R N I N P R A C T I C E
  • 2. Michał Kurzeja CTO @ Accesto TW: @michalKurzeja michal@accesto.com
  • 3. T H I S TA L K S I S A B O U T • Where legacy comes from? • Why it is worth to get rid of legacy… • … and how to make it properly? • How not to hurt yourself • Examples
  • 4. T H I S TA L K I S N O T A B O U T • How to test • How to refactor classes/methods • Silver bullet step-by-step approach
  • 5. Bad practices „Mr Hype” Good practices
 „Dr Strangler”
  • 6. L E G A C Y C O D E
  • 7.
  • 8. L E G A C Y ! = I N H E R I T E D C O D E
  • 9. E X P E C TAT I O N S
  • 10. R E A L I T Y
  • 11. Q U A L I T Y D E C R E A S E S I N T I M E - L A C K O F T H E „ B O Y S C O U T ” R U L E 0 17,5 35 52,5 70 2010 2011 2012 2013
  • 12. R E S U LT S ? I S S U E S : • Complicated code • Harder to write tests • Difficult deployment • Reluctance of developers • Hard to develop
  • 13. H O W T O C O N V I N C E B U S I N E S S • Slower development • competitors might be faster • increased costs • HR issues: harder recruitment, more people leaving • Lots of bugs, angry customers • It might explode at any time ;)
  • 14. 2 0 1 2 , K N I G H T C A P I TA L G R O U P $460 mln loss in 45 minutes
  • 15. W H AT C A N W E D O ?
  • 16. R E W R I T E F R O M S C R AT C H
  • 17. F R O M 9 0 % T O 0 % O F M A R K E T S H A R E D E C L I N E O F N E T S C A P E L O S T I T T O I N T E R N E T E X P L O R E R !
  • 18. K E E P O N G O I N G
  • 19. R E FA C T O R ?
  • 20.
  • 21. Rewrite from scratchKeep on going Refactor STRANGLE! FUN RISK
  • 22. S T R A N G L E R PAT T E R N
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29. G AT E WAY / FA C A D E
  • 30. G AT E WAY - B U I L D I T L E A N server {
 listen 80;
 server_name domain.com;
 
 location /profile {
 proxy_pass http://10.0.3.10:80;
 }
 
 location /news {
 proxy_pass http://10.0.3.10:80;
 }
 
 proxy_pass http://10.0.3.20:80;
 }
  • 31. G AT E WAY - P O S S I B L E S O L U T I O N S • API - Open Source • Kong • API - Paid • AWS API Gateway • WWW • HaProxy • Nginx/Apache/…
  • 32. S TA R T W I T H C AT C H A L L
  • 33.
  • 34. S H A R E D D ATA B A S E
  • 35. D I S T R I B U T E D S H I T
  • 36. S P L I T D ATA B A S E S • Scheduled sync (cron) • Events (required change in legacy) • DB Triggers • Transaction log (Binlog -> Kafka)
  • 37. A P I
  • 38.
  • 39. B O U N D A R I E S
  • 41. A C L
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48. L E G A C Y I N A B O X
  • 49.
  • 50.
  • 51. I N P R A C T I C E
  • 52. L O N G T I M E A G O … • Market leader • Project started in 2010, we took over in 2016 • Customers: banks, political parties - no downtime allowed ;)
  • 53. N O F R O N T- C O N T R O L L E R
  • 54. „ C U T E ” V E R S I O N I N G
  • 55. „ M A G I C ” S T R U C T U R E
  • 56. „ B U L L E T P R O O F ” C O N F I G It was $_SERVER[SERVER_NAME];
  • 57. „ R E A D A B L E ” C O D E
  • 59. S E V E R A L G R AY H A I R L AT E R
  • 60. • Monorepo • Apache as facade • Anti-Corruption Layer -> API • JSON Web Token • Configuration by env variables
  • 61.
  • 62. • 100% automated deployment (on Kubernetes) • Business is very happy • Programmers are still alive (and work for us)
  • 63. M I S TA K E S 
 W H AT C O U L D B E D O N E B E T T E R
  • 64. F E AT U R E T O G G L E
  • 65. J W T F R O M D AY 1 0
  • 66. B E T T E R A C L
  • 67. I S S U E S
  • 68. P R O S • Small risk, less stress, quick releases • Instant effects • Both business and developers happy
  • 69. S E C O N D A P P R O A C H - A C L * * M O D I F I E D A B I T
  • 70. M O D E R N A C L L E G A C Y https://github.com/VaughnVernon/IDDD_Samples/tree/master/iddd_collaboration/src/main/java/com/saasovation/ collaboration/port/adapter/service
  • 71. M O D E R N A C L L E G A C Y APIREPO
  • 72. class Currency { private $isoCode; private $default; private $ratio; } M O D E R N - C U R R E N C Y M O D E L
  • 73. interface CurrencyRepository { public function findAll(); public function getDefault(); public function find(string $isoCode); public function save(Currency $currency); } M O D E R N - C U R R E N C Y R E P O S I T O RY
  • 74. class Internal_CurrencyController extends Internal_Controller_InternalController { public function listcurrenciesAction() { $this->checkIp(); $this->getResponse()->setHeader('Content-type', 'application/json'); $mCurrency = new Default_Model_Currency(); /** @var Zend_Db_Table_Rowset $currencies */ $currencies = $mCurrency->fetchAll('status = "active"'); $this->getResponse() ->setBody(json_encode($currencies->toArray())) ->setHttpResponseCode(200); } } L E G A C Y - C U R R E N C Y FA C A D E
  • 75. interface CurrencyAdapter { public function findAll(): array; } A C L - C U R R E N C Y A P I I N T E R FA C E
  • 76. class LegacyCurrencyAdapter implements CurrencyAdapter { public function findAll(): array { $response = $this->client->request('GET', 'listCurrencies'); $currencies = json_decode((string) $response->getBody(), true); return array_map(function ($row) { $currency = $this->currencyTranslator->createFromArray($row); if ($exCurrency = $this->currRepo->find($currency->isoCode())) { $currency->setRatio($exCurrency->getRatio()); $currency->setDefault($exCurrency->getDefault()); } return $currency; }, $currencies); } } A C L - C U R R E N C Y A P I
  • 77. class LegacyCurrencyTranslator implements CurrencyTranslator { public function createFromArray(array $data) { $default = filter_var($data['default'], FILTER_VALIDATE_BOOLEAN); $ratio = filter_var($data['value'], FILTER_VALIDATE_FLOAT); return new Currency($data['code'], $ratio, $default); } } A C L - C U R R E N C Y T R A N S L AT O R
  • 78. W H AT N O T T O D O
  • 79. R O U T I N G I N L E G A C Y / M O D E R N
  • 80. L A C K O F A N T I - C O R R U P T I O N L AY E R
  • 81. P L A N F I R S T, C O D E L AT E R
  • 82.
  • 83. GETTING STARTED WITH DDD WHEN SURROUNDED BY LEGACY SYSTEMS E R I C E VA N S
  • 84.
  • 85. W R I T E S O F T WA R E T H AT I S E A S Y T O S T R A N G L E
  • 86. Michał Kurzeja CTO @ Accesto @michalKurzeja michal@accesto.com Thanks!