SlideShare a Scribd company logo
Putting Legacy to REST
with Middleware
By:
Adam Culp
Twitter: @adamculp
2
Putting Legacy to REST with Middleware
●
About me
– DevRel and Tech Lead at Nexmo
– OSS Contributor
– PHP-Fig voting member (IBM i Toolkit)
– Organizer SoFloPHP (South Florida)
– Organizer SunshinePHP (Miami)
– Long distance (ultra) runner
– Judo Black Belt Instructor
3
Putting Legacy to REST with Middleware
●
About me
– DevRel and Tech Lead at Nexmo
– OSS Contributor
– PHP-Fig voting member (IBM i Toolkit)
– Organizer SoFloPHP (South Florida)
– Organizer SunshinePHP (Miami)
– Long distance (ultra) runner
– Judo Black Belt Instructor
I am the
PHP Ninja!!!
4
Putting Legacy to REST with Middleware
●
Fan of iteration
– Pretty much everything requires iteration to do well:
●
Long distance running
●
Judo
●
Development
●
Evading project managers
●
Refactoring!
5
Refactoring Legacy Code
●
What is “Legacy Code”?
– Is there a coding standard for your project?
6
Refactoring Legacy Code
●
What is “Legacy Code”?
– Is there a coding standard for your project?
– Is code using OOP?
7
Refactoring Legacy Code
●
What is “Legacy Code”?
– Is there a coding standard for your project?
– Is code using OOP?
– Is Composer used in your project?
8
Refactoring Legacy Code
●
What is “Legacy Code”?
– Is there a coding standard for your project?
– Is code using OOP?
– Is Composer used in your project?
– Is the project using a framework?
9
Refactoring Legacy Code
●
What is “Legacy Code”?
– Is there a coding standard for your project?
– Is code using OOP?
– Is Composer used in your project?
– Is the project using a framework?
– Are you unit testing?
10
Refactoring Legacy Code
●
What is “Legacy Code”?
– Is there a coding standard for your project?
– Is code using OOP?
– Is Composer used in your project?
– Is the project using a framework?
– Are you unit testing?
– Does your project avoid NIH?
11
Refactoring Legacy Code
●
What is “Legacy Code”?
– Is there a coding standard for your project?
– Is code using OOP?
– Is Composer used in your project?
– Is the project using a framework?
– Are you unit testing?
– Does your project avoid NIH?
If you can answer “No” to any of these,
you may be creating “Legacy Code”!!!
12
Refactoring Legacy Code
●
What is “legacy” really?
– According to https://en.wikipedia.org/wiki/Legacy_code
●
“...no longer supported or manufactured...”
●
“...code inserted into modern software for the purpose of maintaining
an older or previously supported feature...”
●
“...supporting older file formats...”
●
“...code may no longer work without changes...”
●
“...code that no longer runs on a later version of a system, or requires
a compatibility layer to do so...”
13
Putting Legacy to REST with Middleware
●
Why Rewrite?
– Change technology (PHP to Javascript, Python, etc.)
– Code is REALLY bad
– If less expensive to rewrite versus refactor
– Little to no chance to lose business logic
– Desire a “different” application
14
Putting Legacy to REST with Middleware
●
API First!
– API is first class citizen
15
Putting Legacy to REST with Middleware
●
API First!
– API is first class citizen
– API comes first, then implementation
16
Putting Legacy to REST with Middleware
●
API First!
– API is first class citizen
– API comes first, then implementation
– Development teams can work in parallel
17
Putting Legacy to REST with Middleware
●
API First!
– API is first class citizen
– API comes first, then implementation
– Development teams can work in parallel
– Reduces cost of developing apps
●
Through re-use of business logic
18
Putting Legacy to REST with Middleware
●
API First!
– API is first class citizen
– API comes first, then implementation
– Development teams can work in parallel
– Reduces cost of developing apps
●
Through re-use of business logic
– Faster time to market
19
Putting Legacy to REST with Middleware
●
API First!
– API is first class citizen
– API comes first, then implementation
– Development teams can work in parallel
– Reduces cost of developing apps
●
Through re-use of business logic
– Faster time to market
– OpenAPI
20
Putting Legacy to REST with Middleware
●
API First!
– API is first class citizen
– API comes first, then implementation
– Development teams can work in parallel
– Reduces cost of developing apps
●
Through re-use of business logic
– Faster time to market
– OpenAPI
– Reduces risk of failure
21
Putting Legacy to REST with Middleware
●
Modernization Methods
22
Putting Legacy to REST with Middleware
●
Modernization Methods
– #1 Total Rewrite
●
Create entirely new app
●
Build until complete
●
Big BANG!
23
Putting Legacy to REST with Middleware
●
Modernization Methods
– #1 Total Rewrite
●
Create entirely new app
●
Build until complete
●
Big BANG!
24
Putting Legacy to REST with Middleware
●
Modernization Methods
– #1 Total Rewrite
●
Create entirely new app
●
Build until complete
●
Big BANG!
●
Pitfalls
– Constant “scope creep”
– Maintain 2 apps
– Expensive!
25
Putting Legacy to REST with Middleware
●
Modernization Methods
– #1 Total Rewrite
●
Create entirely new app
●
Build until complete
●
Big BANG!
●
Pitfalls
– Constant “scope creep”
– Maintain 2 apps
– Expensive!
●
Benefits
– Clean slate
– Energy/Excitement
– Less business disruption
26
Putting Legacy to REST with Middleware
●
Modernization Methods (cont’d)
– #2 REST API Backend
●
Build an API
●
Use the API to drive logic and data
27
Putting Legacy to REST with Middleware
●
Modernization Methods (cont’d)
– #2 REST API Backend
●
Build an API
●
Use the API to drive logic and data
●
Pitfalls
– Requires cleanup of objects first
– Longer time to get productive
– Very difficult for spaghetti apps
28
Putting Legacy to REST with Middleware
●
Modernization Methods (cont’d)
– #2 REST API Backend
●
Build an API
●
Use the API to drive logic and data
●
Pitfalls
– Requires cleanup of objects first
– Longer time to get productive
– Very difficult for spaghetti apps
●
Benefits
– Cleans up data/business logic
– Shorter time to completion
29
Putting Legacy to REST with Middleware
●
Modernization Methods #2 (How-To)
– Create standalone REST API
●
Add one module at a time
30
Putting Legacy to REST with Middleware
●
Modernization Methods #2 (How-To)
– Create standalone REST API
●
Add one module at a time
– Refactor the Legacy application to use API as Service/Model
31
Putting Legacy to REST with Middleware
●
Modernization Methods #2 (How-To)
– Create standalone REST API
●
Add one module at a time
– Refactor the Legacy application to use API as Service/Model
– Eventually API First, w/ frontend application
32
Putting Legacy to REST with Middleware
●
Modernization Methods (cont’d)
– #3 Legacy Middleware
●
New application (as with rewrite)
●
In stages
33
Putting Legacy to REST with Middleware
●
Modernization Methods (cont’d)
– #3 Legacy Middleware
●
New application (as with rewrite)
●
In stages
●
Pitfalls
– Takes upfront planning
– Takes longer
– Overall, still creating 2 new apps
– Not API first until the end
34
Putting Legacy to REST with Middleware
●
Modernization Methods (cont’d)
– #3 Legacy Middleware
●
New application (as with rewrite)
●
In stages
●
Pitfalls
– Takes more planning
– Takes longer
– Overall, still creating 2 new apps
– Not API first until the end
●
Benefits
– Can update/implement new frontend faster (duplicated)
– Spaghetti app easier to manage
– Less business impact
– Marketing “new” features regularly
35
Putting Legacy to REST with Middleware
●
Modernization Methods #3 (How-To)
– New sub-directory for new app
36
Putting Legacy to REST with Middleware
●
Modernization Methods #3 (How-To)
– New sub-directory for new app
– Create LegacyMiddleware, add it before FinalMiddleware
37
Putting Legacy to REST with Middleware
●
Modernization Methods #3 (How-To)
– New sub-directory for new app
– Create LegacyMiddleware, add it before FinalMiddleware
– Fix issues with routing and includes
38
Putting Legacy to REST with Middleware
●
Modernization Methods #3 (How-To)
– New sub-directory for new app
– Create LegacyMiddleware, add it before FinalMiddleware
– Fix issues with routing and includes
– Update doc_root to be new location
●
Site working as it used to
39
Putting Legacy to REST with Middleware
●
Modernization Methods #3 (How-To)
– New sub-directory for new app
– Create LegacyMiddleware, add it before FinalMiddleware
– Fix issues with routing and includes
– Update doc_root to be new location
●
Site working as it used to
– Start creating new modules in new app
40
Putting Legacy to REST with Middleware
●
Modernization Methods #3 (How-To)
– New sub-directory for new app
– Create LegacyMiddleware, add it before FinalMiddleware
– Fix issues with routing and includes
– Update doc_root to be new location
●
Site working as it used to
– Start creating new modules in new app
– LegacyMiddleware called less and less
41
Putting Legacy to REST with Middleware
●
Modernization Methods #3 (How-To)
– New sub-directory for new app
– Create LegacyMiddleware, add it before FinalMiddleware
– Fix issues with routing and includes
– Update doc_root to be new location
●
Site working as it used to
– Start creating new modules in new app
– LegacyMiddleware called less and less
– Remove legacy app once all endpoints satisfied
42
Putting Legacy to REST with Middleware
●
What is “Middleware”?
– NEW? way to build multi-layers as tiered approach to execution
– “Software glue” - wikipedia
●
Implement communication and input/output
●
Popular in ‘80s to link newer applications to legacy systems
43
Putting Legacy to REST with Middleware
●
Frameworks!
– Expressive (Laminas Project, formerly Zend Framework)
– Slim PHP
– Most others:
●
Laravel
●
Symfony
●
Etc.
44
Putting Legacy to REST with Middleware
●
Testing
– Always test prior to refactoring
– Then refactor
– Then test again
– Refactor tests as needed
– Repeat
45
Putting Legacy to REST with Middleware
●
Tools
– Source Control
●
Allows easier rollback
●
Allows collaboration
●
Git makes branching easier
46
Putting Legacy to REST with Middleware
●
Tools (cont’d)
– CI/CD
●
Makes updates across team seamless
47
Putting Legacy to REST with Middleware
●
Conclusion
– Middleware makes modernization easier
– Do it in stages
– Test all the things...often
– Teamwork
– Love iteration!
48
Putting Legacy to REST with Middleware
●
Go!
– Your turn!
●
Thank you!
– Code: https://github.com/adamculp/
Adam Culp
https://beachcasts.com
https://geekyboy.com
https://rungeekradio.com
Twitter @adamculp
Questions?

More Related Content

What's hot (20)

PDF
Hopper services
hopperdev
 
PPTX
Manila MuleSoft Meetup - May 2018
Ryan Anthony Andal
 
PPTX
Manila MuleSoft Meetup #4 January 2019
Christopher Co
 
PPTX
mulesoft meetup @ bangalore
D.Rajesh Kumar
 
PDF
DevOps:建造開發維運的跨界之橋 (@ C.C. Agile #37)
Chen Cheng-Wei
 
PDF
MuleSoft approach to the integration - Warsaw MuleSoft Meetup
Patryk Bandurski
 
PPTX
Ruby conf
Shweta Kale
 
PDF
MuleSoft Milano Meetup #7 Florence Consulting
Florence Consulting
 
PDF
Rich Ajax Platform - theEdge 2012 conference presentation
Nicko Borodachuk
 
PDF
Sydney MuleSoft Meetup #16 - 19 November 2020
Royston Lobo
 
PPTX
Manila MuleSoft Meetup - July 2019
Ryan Anthony Andal
 
PDF
Designing APIs with OpenAPI Spec
Adam Paxton
 
PDF
Building APIs with the OpenApi Spec
Pedro J. Molina
 
PPTX
Two Unique Challenges NetApp has tackled while Implementing Machine Translati...
TAUS - The Language Data Network
 
PPTX
MuleSoft São Paulo Meetup #3 - 18 Jun
Guilherme Pereira Silva
 
PPTX
Real-Time Metrics and Distributed Monitoring - Jeff Pierce, Change.org - Dev...
DevOpsDays Tel Aviv
 
PDF
Front-end for Java developers Devoxx France 2018
Deepu K Sasidharan
 
PPTX
Java 10 and beyond: Keeping up with the language and planning for the future
Rogue Wave Software
 
PDF
The API Lifecycle Series: Evolving API Development and Testing from Open Sour...
SmartBear
 
PDF
Mule 4 meetup @Hyderabad
Vijay Reddy
 
Hopper services
hopperdev
 
Manila MuleSoft Meetup - May 2018
Ryan Anthony Andal
 
Manila MuleSoft Meetup #4 January 2019
Christopher Co
 
mulesoft meetup @ bangalore
D.Rajesh Kumar
 
DevOps:建造開發維運的跨界之橋 (@ C.C. Agile #37)
Chen Cheng-Wei
 
MuleSoft approach to the integration - Warsaw MuleSoft Meetup
Patryk Bandurski
 
Ruby conf
Shweta Kale
 
MuleSoft Milano Meetup #7 Florence Consulting
Florence Consulting
 
Rich Ajax Platform - theEdge 2012 conference presentation
Nicko Borodachuk
 
Sydney MuleSoft Meetup #16 - 19 November 2020
Royston Lobo
 
Manila MuleSoft Meetup - July 2019
Ryan Anthony Andal
 
Designing APIs with OpenAPI Spec
Adam Paxton
 
Building APIs with the OpenApi Spec
Pedro J. Molina
 
Two Unique Challenges NetApp has tackled while Implementing Machine Translati...
TAUS - The Language Data Network
 
MuleSoft São Paulo Meetup #3 - 18 Jun
Guilherme Pereira Silva
 
Real-Time Metrics and Distributed Monitoring - Jeff Pierce, Change.org - Dev...
DevOpsDays Tel Aviv
 
Front-end for Java developers Devoxx France 2018
Deepu K Sasidharan
 
Java 10 and beyond: Keeping up with the language and planning for the future
Rogue Wave Software
 
The API Lifecycle Series: Evolving API Development and Testing from Open Sour...
SmartBear
 
Mule 4 meetup @Hyderabad
Vijay Reddy
 

Similar to Putting legacy to REST with middleware (20)

PDF
What is REST?
Saeid Zebardast
 
PPTX
REST Methodologies
jrodbx
 
PPTX
Building Software Backend (Web API)
Alexander Goida
 
PDF
Reengineering Legacy Software Chris Birchall
mattyychonr
 
PPTX
rest-api-basics.pptx
AgungSutikno1
 
PDF
REST in pieces
sparkfabrik
 
PDF
[drupalday2017] - REST in pieces
DrupalDay
 
PPTX
Symfony2 for legacy app rejuvenation: the eZ Publish case study
Gaetano Giunta
 
PDF
Creating Restful Web Services with restish
Grig Gheorghiu
 
PDF
REST APIS web development for backend familiarity
ARTUROGOMEZGARCIA2
 
PPTX
L18 REST API Design
Ólafur Andri Ragnarsson
 
PDF
GlueCon 2018: Are REST APIs Still Relevant Today?
LaunchAny
 
ODP
Microservices
Karol Grzegorczyk
 
PPTX
How do we drive tech changes
Jaewoo Ahn
 
PDF
Better Laziness Through Hypermedia -- Designing a Hypermedia Client
Pete Gamache
 
PDF
REST Api with Asp Core
Irina Scurtu
 
PPTX
Your API is Bad and You Should Feel Bad
Amanda Folson
 
PPTX
rest-api-basics.pptx
FikiRieza2
 
PPSX
Restful web services rule financial
Rule_Financial
 
PDF
09-01-services-slides.pdf for educations
katariraju71
 
What is REST?
Saeid Zebardast
 
REST Methodologies
jrodbx
 
Building Software Backend (Web API)
Alexander Goida
 
Reengineering Legacy Software Chris Birchall
mattyychonr
 
rest-api-basics.pptx
AgungSutikno1
 
REST in pieces
sparkfabrik
 
[drupalday2017] - REST in pieces
DrupalDay
 
Symfony2 for legacy app rejuvenation: the eZ Publish case study
Gaetano Giunta
 
Creating Restful Web Services with restish
Grig Gheorghiu
 
REST APIS web development for backend familiarity
ARTUROGOMEZGARCIA2
 
L18 REST API Design
Ólafur Andri Ragnarsson
 
GlueCon 2018: Are REST APIs Still Relevant Today?
LaunchAny
 
Microservices
Karol Grzegorczyk
 
How do we drive tech changes
Jaewoo Ahn
 
Better Laziness Through Hypermedia -- Designing a Hypermedia Client
Pete Gamache
 
REST Api with Asp Core
Irina Scurtu
 
Your API is Bad and You Should Feel Bad
Amanda Folson
 
rest-api-basics.pptx
FikiRieza2
 
Restful web services rule financial
Rule_Financial
 
09-01-services-slides.pdf for educations
katariraju71
 
Ad

More from Adam Culp (20)

PDF
Release your refactoring superpower
Adam Culp
 
PDF
Managing Technical Debt
Adam Culp
 
PDF
Developing PHP Applications Faster
Adam Culp
 
PDF
Containing Quality
Adam Culp
 
PDF
Debugging elephpants
Adam Culp
 
PDF
Zend expressive workshop
Adam Culp
 
PDF
Expressive Microservice Framework Blastoff
Adam Culp
 
PDF
Foundations of Zend Framework
Adam Culp
 
PDF
Accidental professional
Adam Culp
 
PDF
Build great products
Adam Culp
 
PDF
Does Your Code Measure Up?
Adam Culp
 
PDF
Practical PHP Deployment with Jenkins
Adam Culp
 
PDF
Virtualizing Development
Adam Culp
 
PDF
Refactoring Legacy Code
Adam Culp
 
PDF
Deprecated: Foundations of Zend Framework 2
Adam Culp
 
PDF
Clean application development tutorial
Adam Culp
 
PDF
Refactoring 101
Adam Culp
 
PDF
Essential git for developers
Adam Culp
 
PDF
Vagrant for Virtualized Development
Adam Culp
 
PDF
Clean application development (talk)
Adam Culp
 
Release your refactoring superpower
Adam Culp
 
Managing Technical Debt
Adam Culp
 
Developing PHP Applications Faster
Adam Culp
 
Containing Quality
Adam Culp
 
Debugging elephpants
Adam Culp
 
Zend expressive workshop
Adam Culp
 
Expressive Microservice Framework Blastoff
Adam Culp
 
Foundations of Zend Framework
Adam Culp
 
Accidental professional
Adam Culp
 
Build great products
Adam Culp
 
Does Your Code Measure Up?
Adam Culp
 
Practical PHP Deployment with Jenkins
Adam Culp
 
Virtualizing Development
Adam Culp
 
Refactoring Legacy Code
Adam Culp
 
Deprecated: Foundations of Zend Framework 2
Adam Culp
 
Clean application development tutorial
Adam Culp
 
Refactoring 101
Adam Culp
 
Essential git for developers
Adam Culp
 
Vagrant for Virtualized Development
Adam Culp
 
Clean application development (talk)
Adam Culp
 
Ad

Recently uploaded (20)

PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 

Putting legacy to REST with middleware

  • 1. Putting Legacy to REST with Middleware By: Adam Culp Twitter: @adamculp
  • 2. 2 Putting Legacy to REST with Middleware ● About me – DevRel and Tech Lead at Nexmo – OSS Contributor – PHP-Fig voting member (IBM i Toolkit) – Organizer SoFloPHP (South Florida) – Organizer SunshinePHP (Miami) – Long distance (ultra) runner – Judo Black Belt Instructor
  • 3. 3 Putting Legacy to REST with Middleware ● About me – DevRel and Tech Lead at Nexmo – OSS Contributor – PHP-Fig voting member (IBM i Toolkit) – Organizer SoFloPHP (South Florida) – Organizer SunshinePHP (Miami) – Long distance (ultra) runner – Judo Black Belt Instructor I am the PHP Ninja!!!
  • 4. 4 Putting Legacy to REST with Middleware ● Fan of iteration – Pretty much everything requires iteration to do well: ● Long distance running ● Judo ● Development ● Evading project managers ● Refactoring!
  • 5. 5 Refactoring Legacy Code ● What is “Legacy Code”? – Is there a coding standard for your project?
  • 6. 6 Refactoring Legacy Code ● What is “Legacy Code”? – Is there a coding standard for your project? – Is code using OOP?
  • 7. 7 Refactoring Legacy Code ● What is “Legacy Code”? – Is there a coding standard for your project? – Is code using OOP? – Is Composer used in your project?
  • 8. 8 Refactoring Legacy Code ● What is “Legacy Code”? – Is there a coding standard for your project? – Is code using OOP? – Is Composer used in your project? – Is the project using a framework?
  • 9. 9 Refactoring Legacy Code ● What is “Legacy Code”? – Is there a coding standard for your project? – Is code using OOP? – Is Composer used in your project? – Is the project using a framework? – Are you unit testing?
  • 10. 10 Refactoring Legacy Code ● What is “Legacy Code”? – Is there a coding standard for your project? – Is code using OOP? – Is Composer used in your project? – Is the project using a framework? – Are you unit testing? – Does your project avoid NIH?
  • 11. 11 Refactoring Legacy Code ● What is “Legacy Code”? – Is there a coding standard for your project? – Is code using OOP? – Is Composer used in your project? – Is the project using a framework? – Are you unit testing? – Does your project avoid NIH? If you can answer “No” to any of these, you may be creating “Legacy Code”!!!
  • 12. 12 Refactoring Legacy Code ● What is “legacy” really? – According to https://en.wikipedia.org/wiki/Legacy_code ● “...no longer supported or manufactured...” ● “...code inserted into modern software for the purpose of maintaining an older or previously supported feature...” ● “...supporting older file formats...” ● “...code may no longer work without changes...” ● “...code that no longer runs on a later version of a system, or requires a compatibility layer to do so...”
  • 13. 13 Putting Legacy to REST with Middleware ● Why Rewrite? – Change technology (PHP to Javascript, Python, etc.) – Code is REALLY bad – If less expensive to rewrite versus refactor – Little to no chance to lose business logic – Desire a “different” application
  • 14. 14 Putting Legacy to REST with Middleware ● API First! – API is first class citizen
  • 15. 15 Putting Legacy to REST with Middleware ● API First! – API is first class citizen – API comes first, then implementation
  • 16. 16 Putting Legacy to REST with Middleware ● API First! – API is first class citizen – API comes first, then implementation – Development teams can work in parallel
  • 17. 17 Putting Legacy to REST with Middleware ● API First! – API is first class citizen – API comes first, then implementation – Development teams can work in parallel – Reduces cost of developing apps ● Through re-use of business logic
  • 18. 18 Putting Legacy to REST with Middleware ● API First! – API is first class citizen – API comes first, then implementation – Development teams can work in parallel – Reduces cost of developing apps ● Through re-use of business logic – Faster time to market
  • 19. 19 Putting Legacy to REST with Middleware ● API First! – API is first class citizen – API comes first, then implementation – Development teams can work in parallel – Reduces cost of developing apps ● Through re-use of business logic – Faster time to market – OpenAPI
  • 20. 20 Putting Legacy to REST with Middleware ● API First! – API is first class citizen – API comes first, then implementation – Development teams can work in parallel – Reduces cost of developing apps ● Through re-use of business logic – Faster time to market – OpenAPI – Reduces risk of failure
  • 21. 21 Putting Legacy to REST with Middleware ● Modernization Methods
  • 22. 22 Putting Legacy to REST with Middleware ● Modernization Methods – #1 Total Rewrite ● Create entirely new app ● Build until complete ● Big BANG!
  • 23. 23 Putting Legacy to REST with Middleware ● Modernization Methods – #1 Total Rewrite ● Create entirely new app ● Build until complete ● Big BANG!
  • 24. 24 Putting Legacy to REST with Middleware ● Modernization Methods – #1 Total Rewrite ● Create entirely new app ● Build until complete ● Big BANG! ● Pitfalls – Constant “scope creep” – Maintain 2 apps – Expensive!
  • 25. 25 Putting Legacy to REST with Middleware ● Modernization Methods – #1 Total Rewrite ● Create entirely new app ● Build until complete ● Big BANG! ● Pitfalls – Constant “scope creep” – Maintain 2 apps – Expensive! ● Benefits – Clean slate – Energy/Excitement – Less business disruption
  • 26. 26 Putting Legacy to REST with Middleware ● Modernization Methods (cont’d) – #2 REST API Backend ● Build an API ● Use the API to drive logic and data
  • 27. 27 Putting Legacy to REST with Middleware ● Modernization Methods (cont’d) – #2 REST API Backend ● Build an API ● Use the API to drive logic and data ● Pitfalls – Requires cleanup of objects first – Longer time to get productive – Very difficult for spaghetti apps
  • 28. 28 Putting Legacy to REST with Middleware ● Modernization Methods (cont’d) – #2 REST API Backend ● Build an API ● Use the API to drive logic and data ● Pitfalls – Requires cleanup of objects first – Longer time to get productive – Very difficult for spaghetti apps ● Benefits – Cleans up data/business logic – Shorter time to completion
  • 29. 29 Putting Legacy to REST with Middleware ● Modernization Methods #2 (How-To) – Create standalone REST API ● Add one module at a time
  • 30. 30 Putting Legacy to REST with Middleware ● Modernization Methods #2 (How-To) – Create standalone REST API ● Add one module at a time – Refactor the Legacy application to use API as Service/Model
  • 31. 31 Putting Legacy to REST with Middleware ● Modernization Methods #2 (How-To) – Create standalone REST API ● Add one module at a time – Refactor the Legacy application to use API as Service/Model – Eventually API First, w/ frontend application
  • 32. 32 Putting Legacy to REST with Middleware ● Modernization Methods (cont’d) – #3 Legacy Middleware ● New application (as with rewrite) ● In stages
  • 33. 33 Putting Legacy to REST with Middleware ● Modernization Methods (cont’d) – #3 Legacy Middleware ● New application (as with rewrite) ● In stages ● Pitfalls – Takes upfront planning – Takes longer – Overall, still creating 2 new apps – Not API first until the end
  • 34. 34 Putting Legacy to REST with Middleware ● Modernization Methods (cont’d) – #3 Legacy Middleware ● New application (as with rewrite) ● In stages ● Pitfalls – Takes more planning – Takes longer – Overall, still creating 2 new apps – Not API first until the end ● Benefits – Can update/implement new frontend faster (duplicated) – Spaghetti app easier to manage – Less business impact – Marketing “new” features regularly
  • 35. 35 Putting Legacy to REST with Middleware ● Modernization Methods #3 (How-To) – New sub-directory for new app
  • 36. 36 Putting Legacy to REST with Middleware ● Modernization Methods #3 (How-To) – New sub-directory for new app – Create LegacyMiddleware, add it before FinalMiddleware
  • 37. 37 Putting Legacy to REST with Middleware ● Modernization Methods #3 (How-To) – New sub-directory for new app – Create LegacyMiddleware, add it before FinalMiddleware – Fix issues with routing and includes
  • 38. 38 Putting Legacy to REST with Middleware ● Modernization Methods #3 (How-To) – New sub-directory for new app – Create LegacyMiddleware, add it before FinalMiddleware – Fix issues with routing and includes – Update doc_root to be new location ● Site working as it used to
  • 39. 39 Putting Legacy to REST with Middleware ● Modernization Methods #3 (How-To) – New sub-directory for new app – Create LegacyMiddleware, add it before FinalMiddleware – Fix issues with routing and includes – Update doc_root to be new location ● Site working as it used to – Start creating new modules in new app
  • 40. 40 Putting Legacy to REST with Middleware ● Modernization Methods #3 (How-To) – New sub-directory for new app – Create LegacyMiddleware, add it before FinalMiddleware – Fix issues with routing and includes – Update doc_root to be new location ● Site working as it used to – Start creating new modules in new app – LegacyMiddleware called less and less
  • 41. 41 Putting Legacy to REST with Middleware ● Modernization Methods #3 (How-To) – New sub-directory for new app – Create LegacyMiddleware, add it before FinalMiddleware – Fix issues with routing and includes – Update doc_root to be new location ● Site working as it used to – Start creating new modules in new app – LegacyMiddleware called less and less – Remove legacy app once all endpoints satisfied
  • 42. 42 Putting Legacy to REST with Middleware ● What is “Middleware”? – NEW? way to build multi-layers as tiered approach to execution – “Software glue” - wikipedia ● Implement communication and input/output ● Popular in ‘80s to link newer applications to legacy systems
  • 43. 43 Putting Legacy to REST with Middleware ● Frameworks! – Expressive (Laminas Project, formerly Zend Framework) – Slim PHP – Most others: ● Laravel ● Symfony ● Etc.
  • 44. 44 Putting Legacy to REST with Middleware ● Testing – Always test prior to refactoring – Then refactor – Then test again – Refactor tests as needed – Repeat
  • 45. 45 Putting Legacy to REST with Middleware ● Tools – Source Control ● Allows easier rollback ● Allows collaboration ● Git makes branching easier
  • 46. 46 Putting Legacy to REST with Middleware ● Tools (cont’d) – CI/CD ● Makes updates across team seamless
  • 47. 47 Putting Legacy to REST with Middleware ● Conclusion – Middleware makes modernization easier – Do it in stages – Test all the things...often – Teamwork – Love iteration!
  • 48. 48 Putting Legacy to REST with Middleware ● Go! – Your turn!
  • 49. ● Thank you! – Code: https://github.com/adamculp/ Adam Culp https://beachcasts.com https://geekyboy.com https://rungeekradio.com Twitter @adamculp Questions?