SlideShare a Scribd company logo
So You Just Inherited a
$Legacy Application...
https://legacy.joind.in/18603
Joe Ferguson
Who Am I?
Joe Ferguson
PHP Developer
Engineer @ Aol.
Twitter: @JoePFerguson
Organizer of @MemphisPHP
@NomadPHP Lightning Talks
Passionate about Community
For Further Reading
leanpub.com/mlaphpleanpub.com/minimumviabletests
Legacy Applications
First: A Warning
“There are no solutions,
only trade offs”
- Joe Ferguson
- Paul M. Jones
- Thomas Sowell
What is a "Legacy" application
Legacy is often used for an older production
application that was written before, or without
regard for modern technologies or practices.
If you ask Wikipedia…
"... no-longer supported …"
"... maintained by an administrator that did not develop the code
…"
"... supporting older file formats ..."
https://en.wikipedia.org/wiki/Legacy_code
Modern Interpretation
"... source code inherited from someone else …"
"... source code inherited from an older version of the software ..."
Some people say…
"Any code in production is not legacy”
"Any code written X years ago is legacy"
Legacy is all these things
As we talk about Legacy code here,
we're really talking about all of these definitions
This process is not Legacy
Specific…
Inheriting a Legacy App
Precontemplation or Shock/Disbelief
Contemplation and/or Anger
Determination and Bargaining
Action and Reconstruction
Maintenance and Acceptance
Precontemplation or Shock/
Disbelief
This is the initial
"what is this?!"
That’s now how this works!
Precontemplation
Not ready for change (project, code base, etc)
Usually you don’t know the depths of issues
Can sometimes lead to assuming the worst
Usually this is the shortest phase due to business needs
Shock/Disbelief
This is where the WTFs and the WTHs should be left
Try to work through any negativity here
Be positive about the previous developer’s intentions
Contemplation and/or Anger
This is the planning phase
Try to get all of your ager at the code
base out during this phase, it will help
you see the path forward.
Taking stock of what we’re
working with
Initial Project Overview
Is there a framework?
Is there a coding standard?
Is there any autoloading?
How are dependencies behind handled?
Is there an ORM or how is the database being utilized?
Is there a development environment?
Is there a framework?
Is there a coding standard?
No Standard? No problem!
Is there any autoloading?
There is a PSR for that…
How are dependencies behind
handled?
Is there an ORM or how is the
database being utilized?
Is there a development
environment?
Tools to help
PHP Coding Standards Fixer
http://cs.sensiolabs.org/
PHP Coding Standards Fixer
php-cs-fixer fix app --dry-run
PHP Mess Detector
https://phpmd.org
PHP Mess Detector
https://phpmd.org
$ phpmd app html cleancode --reportfile report.html
Warning about Automating
Code Changes
Composer
https://getcomposer.org/doc/01-basic-usage.md
Doctrine
http://www.doctrine-project.org
Propel
http://propelorm.org
Local Dev Environments
Physical Hardware
Vagrant (Virtual Machines)
Docker (Containers)
Physical Hardware
Vagrant
PuPHPet.com
So You Just Inherited a $Legacy Application… NomadPHP July 2016
Docker For Developers
leanpub.com/dockerfordevs
Determination and Bargaining
Decision making and triage time
Triage
Address any critical things found in Contemplation phase
PHP version issues
Fixing critical vulnerabilities
You have a plan and now you
need to estimate this plan.
I hate estimating
nomadphp.com/2016/04/06/stop-
multiplying-4/
Lightning talk by Chuck Reeves
(@manchuck)
Short and sweet talk about how to
do better estimating
No Question Left Behind!
The application has no framework, We’re going to use a micro
framework as we refactor.
The application has no autoloading, But we’re using Composer
Dependencies are checked into version control, But we’re using
Composer
There is no ORM, but we’re going to use Propel
We have no dev environment but we’re going to use Vagrant
Proof of Concept
Any new things introduced should be tested to ensure
functionality
Build out a small example of an area you or the team doesn't fully
comprehend so you can address any questions that may arise
Bargaining
Getting stakeholders on board with your estimates
Do the decisions made thus far make business sense?
Are there any doubts in the plan?
“We should just rewrite the app”
"This would be so much easier in
framework _____________”
Why not rewrite?
Progress halts entirely
Business logic is rarely reused
Most of the time is getting back to
current functionality
Why you should refactor
Progress continues
Business logic reused
Modernizing functionality instead
of recreating
Make Decisions
Build Proof of Concept(s)
Ensure stakeholder buy in
Avoid the allure of green fields**
** in some cases a rewrite is warranted
Action and Reconstruction
Existing Tests
This is great!
Review the tests to get an idea of coverage
Passing tests become your control for any upcoming changes
Confidence++
No Existing Tests
Not the end of the world!
Inspect the code base, was it written to be easily testable?
Could you easily mock dependencies?
Untestable Code
Not all code is testable
If you can’t easily unit test the code base, consider alternatives
Functional testing and Acceptance testing are valid options
Acceptance Testing
NOT a replacement for Unit Testing
Test large parts of your application at a time
Can be harder to pinpoint error location
Gives large code coverage in short amount of time
Digging into the Code
Code Consolidation
Digging into the Code
Code Consolidation
Replace globals with DI
Digging into the Code
Code Consolidation
Replace globals with Dependency Injection
Write tests
Digging into the Code
Code Consolidation
Replace globals with Dependency Injection
Write tests
Extract SQL (to ORM or other)
Digging into the Code
Code Consolidation
Replace globals with Dependency Injection
Write tests
Extract SQL (to ORM or other)
Extract Business Logic (To domain logic)
Digging into the Code
Code Consolidation
Replace globals with Dependency Injection
Write tests
Extract SQL (to ORM or other)
Extract Business Logic (To domain logic)
Extract Presentation Logic to Views (Twig, Blade, etc)
Digging into the Code
Code Consolidation
Replace globals with Dependency Injection
Write tests
Extract SQL (to ORM or other)
Extract Business Logic (To domain logic)
Extract Presentation Logic to Views (Twig, Blade, etc)
Extract Action Logic (To Controllers)
Digging into the Code
Code Consolidation
Replace globals with Dependency Injection
Write tests
Extract SQL (to ORM or other)
Extract Business Logic (To domain logic)
Extract Presentation Logic to Views (Twig, Blade, etc)
Extract Action Logic (To Controllers)
Write (more) tests
Maintenance and Acceptance
Maintenance and Acceptance
Code Consolidation
Replace globals with Dependency Injection
Write tests
Extract SQL (to ORM or other)
Extract Business Logic (To domain logic)
Extract Presentation Logic to Views (Twig, Blade, etc)
Extract Action Logic (To Controllers)
Write (more) tests
Maintenance and Acceptance
Adding Features
More New Code
Less Refactoring
Maintain your processes
Continuous Integration
Revisit Acceptance Tests
Resources / Q & A
Modernizing Legacy Applications In PHP - Paul M. Jones
https://leanpub.com/mlaphp
Minimum Viable Tests - Chris Hartjes
https://leanpub.com/minimumviabletests
Code Style https://github.com/FriendsOfPHP/PHP-CS-Fixer, http://editorconfig.org
php mess detector https://phpmd.org
Autoloading PSR-4 https://getcomposer.org/doc/01-basic-usage.md
ORMs http://www.doctrine-project.org http://propelorm.org
Docker https://leanpub.com/dockerfordevs, Vagrant https://puphpet.com
Feedback!
https://legacy.joind.in/18603
Joe Ferguson
Twitter: @JoePFerguson
Email: joe@joeferguson.me
Freenode: joepferguson
Contact Info:

More Related Content

PDF
So You Just Inherited a $Legacy Application...
PDF
Console Apps: php artisan forthe:win
PPTX
Story Testing Approach for Enterprise Applications using Selenium Framework
PDF
Throwing Laravel into your Legacy App™
PDF
How To Use Selenium Successfully (Java Edition)
ODP
Integration Testing in Python
PDF
Codeception
PDF
Testing with Codeception
So You Just Inherited a $Legacy Application...
Console Apps: php artisan forthe:win
Story Testing Approach for Enterprise Applications using Selenium Framework
Throwing Laravel into your Legacy App™
How To Use Selenium Successfully (Java Edition)
Integration Testing in Python
Codeception
Testing with Codeception

What's hot (20)

PDF
Awesome Test Automation Made Simple w/ Dave Haeffner
PPTX
Automated Acceptance Tests & Tool choice
PDF
Mastering Test Automation: How to Use Selenium Successfully
PPTX
[AnDevCon 2016] Mutation Testing for Android
PDF
Java Test Automation for REST, Web and Mobile
PDF
Create an architecture for web test automation
PPTX
CI / CD w/ Codeception
PDF
Codeception introduction and use in Yii
PPTX
Colorful world-of-visual-automation-testing-latest
PDF
Efficient JavaScript Unit Testing, JavaOne China 2013
PDF
Acceptance & Functional Testing with Codeception - SunshinePHP 2016
PDF
Trust Your Pipeline - Automatically Testing and End-to-End Java Application
PPT
Test automation process
PDF
Testing PHP with Codeception
PDF
Shift left-csun-sagar-barbhaya
PPTX
Api testing
PDF
Diffy : Automatic Testing of Microservices @ Twitter
PPTX
Selenium Interview Questions And Answers | Selenium Interview Questions | Sel...
PDF
Robot Framework Introduction & Sauce Labs Integration
PPTX
How to Get Started with Cypress
Awesome Test Automation Made Simple w/ Dave Haeffner
Automated Acceptance Tests & Tool choice
Mastering Test Automation: How to Use Selenium Successfully
[AnDevCon 2016] Mutation Testing for Android
Java Test Automation for REST, Web and Mobile
Create an architecture for web test automation
CI / CD w/ Codeception
Codeception introduction and use in Yii
Colorful world-of-visual-automation-testing-latest
Efficient JavaScript Unit Testing, JavaOne China 2013
Acceptance & Functional Testing with Codeception - SunshinePHP 2016
Trust Your Pipeline - Automatically Testing and End-to-End Java Application
Test automation process
Testing PHP with Codeception
Shift left-csun-sagar-barbhaya
Api testing
Diffy : Automatic Testing of Microservices @ Twitter
Selenium Interview Questions And Answers | Selenium Interview Questions | Sel...
Robot Framework Introduction & Sauce Labs Integration
How to Get Started with Cypress
Ad

Similar to So You Just Inherited a $Legacy Application… NomadPHP July 2016 (20)

PDF
Reduce Reuse Refactor
PDF
Code Coverage for Total Security in Application Migrations
PDF
PHP 4? OMG! A small vademecum for obsolete software migration.
PDF
Test driven development - Zombie proof your code
PDF
The bigrewrite
PDF
Brutal refactoring, lying code, the Churn, and other emotional stories from L...
PPTX
The bigrewrite
PDF
Developing sustainable php projects
PDF
From dev to ops and beyond - getting it done
PDF
Refactoring Legacy Code
PPTX
Novelty in Non-Greenfield
PDF
Your code are my tests
PDF
Workshop: Refactoring Legacy PHP: The Complete Guide
PDF
Introducing TDD to your project
PDF
The rocket internet experience @ PHP.TO.START 2013 in Turin
PPTX
Continuous feature-development
PDF
Modernizing Legacy Applications in PHP, por Paul Jones
PDF
Living With Legacy Code
PDF
Old Code, New Tricks
KEY
PHP Industrialization
Reduce Reuse Refactor
Code Coverage for Total Security in Application Migrations
PHP 4? OMG! A small vademecum for obsolete software migration.
Test driven development - Zombie proof your code
The bigrewrite
Brutal refactoring, lying code, the Churn, and other emotional stories from L...
The bigrewrite
Developing sustainable php projects
From dev to ops and beyond - getting it done
Refactoring Legacy Code
Novelty in Non-Greenfield
Your code are my tests
Workshop: Refactoring Legacy PHP: The Complete Guide
Introducing TDD to your project
The rocket internet experience @ PHP.TO.START 2013 in Turin
Continuous feature-development
Modernizing Legacy Applications in PHP, por Paul Jones
Living With Legacy Code
Old Code, New Tricks
PHP Industrialization
Ad

More from Joe Ferguson (20)

PDF
Modern infrastructure as code with ansible cake fest 2021
PDF
Modern infrastructure as code with ansible PyTN
PDF
Slim PHP when you don't need the kitchen sink
PDF
DevSpace Conf 2017 - Making sense of the provisioning circus
PDF
Release and-dependency-management memphis python
PDF
Composer at Scale, Release and Dependency Management
PDF
Put an end to regression with codeception testing
PDF
Midwest PHP 2017 DevOps For Small team
PDF
All the Laravel Things – Up & Running to Making $$
PDF
Console Apps: php artisan forthe:win
PDF
All the Laravel things: up and running to making $$
PDF
Laravel Forge: Hello World to Hello Production
PDF
MidwestPHP 2016 - Adventures in Laravel 5
PDF
Adventures in Laravel 5 SunshinePHP 2016 Tutorial
PDF
php[world] 2015 Laravel 5.1: From Homestead to the Cloud
PDF
php[world] 2015 Training - Laravel from the Ground Up
PDF
Madison PHP 2015 - DevOps For Small Teams
PDF
ZendCon 2015 - DevOps for Small Teams
PDF
ZendCon 2015 - Laravel Forge: Hello World to Hello Production
PDF
Secure Form Processing and Protection - Devspace 2015
Modern infrastructure as code with ansible cake fest 2021
Modern infrastructure as code with ansible PyTN
Slim PHP when you don't need the kitchen sink
DevSpace Conf 2017 - Making sense of the provisioning circus
Release and-dependency-management memphis python
Composer at Scale, Release and Dependency Management
Put an end to regression with codeception testing
Midwest PHP 2017 DevOps For Small team
All the Laravel Things – Up & Running to Making $$
Console Apps: php artisan forthe:win
All the Laravel things: up and running to making $$
Laravel Forge: Hello World to Hello Production
MidwestPHP 2016 - Adventures in Laravel 5
Adventures in Laravel 5 SunshinePHP 2016 Tutorial
php[world] 2015 Laravel 5.1: From Homestead to the Cloud
php[world] 2015 Training - Laravel from the Ground Up
Madison PHP 2015 - DevOps For Small Teams
ZendCon 2015 - DevOps for Small Teams
ZendCon 2015 - Laravel Forge: Hello World to Hello Production
Secure Form Processing and Protection - Devspace 2015

Recently uploaded (20)

PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Approach and Philosophy of On baking technology
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Electronic commerce courselecture one. Pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
KodekX | Application Modernization Development
PPT
Teaching material agriculture food technology
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Building Integrated photovoltaic BIPV_UPV.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Reach Out and Touch Someone: Haptics and Empathic Computing
Approach and Philosophy of On baking technology
Mobile App Security Testing_ A Comprehensive Guide.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Per capita expenditure prediction using model stacking based on satellite ima...
Electronic commerce courselecture one. Pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Empathic Computing: Creating Shared Understanding
Unlocking AI with Model Context Protocol (MCP)
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Network Security Unit 5.pdf for BCA BBA.
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Big Data Technologies - Introduction.pptx
KodekX | Application Modernization Development
Teaching material agriculture food technology

So You Just Inherited a $Legacy Application… NomadPHP July 2016