SlideShare a Scribd company logo
So You Just Inherited a
$Legacy Application...
https://joind.in/talk/4d6d9
Joe Ferguson
Who Am I?
Joe Ferguson
PHP Developer
Twitter: @JoePFerguson
Organizer of @MemphisPHP
@NomadPHP Lightning Talks
PHP FIG Secretary
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...
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://joind.in/talk/4d6d9
Joe Ferguson
Twitter: @JoePFerguson
Email: joe@joeferguson.me
Freenode: joepferguson
Contact Info:

More Related Content

PDF
So You Just Inherited a $Legacy Application… NomadPHP July 2016
PDF
Laravel Forge: Hello World to Hello Production
PDF
Console Apps: php artisan forthe:win
PPTX
Story Testing Approach for Enterprise Applications using Selenium Framework
PDF
Codeception
PDF
How To Use Selenium Successfully (Java Edition)
ODP
Integration Testing in Python
PDF
Testing with Codeception
So You Just Inherited a $Legacy Application… NomadPHP July 2016
Laravel Forge: Hello World to Hello Production
Console Apps: php artisan forthe:win
Story Testing Approach for Enterprise Applications using Selenium Framework
Codeception
How To Use Selenium Successfully (Java Edition)
Integration Testing in Python
Testing with Codeception

What's hot (20)

PDF
Codeception introduction and use in Yii
PPTX
CI / CD w/ Codeception
PDF
Acceptance & Functional Testing with Codeception - SunshinePHP 2016
PPTX
Agility Requires Safety
PDF
Mastering Test Automation: How to Use Selenium Successfully
PPTX
[AnDevCon 2016] Mutation Testing for Android
PPTX
Test automation with php codeception
PDF
Testing PHP with Codeception
PDF
Efficient JavaScript Unit Testing, JavaOne China 2013
PDF
Continuous Integration Testing in Django
PDF
Drupalcamp Simpletest
PDF
Selenium RC: Automated Testing of Modern Web Applications
PDF
Trust Your Pipeline - Automatically Testing and End-to-End Java Application
PPT
Introduction To Eclipse RCP
PPTX
Selenium Interview Questions And Answers | Selenium Interview Questions | Sel...
PPTX
API Testing with Open Source Code and Cucumber
PPTX
Selenium basic
PDF
PhoneGap JavaScript API vs Native Components
PDF
Selenium Interview Questions and Answers For Freshers And Experienced | Edureka
PDF
React a11y-csun
Codeception introduction and use in Yii
CI / CD w/ Codeception
Acceptance & Functional Testing with Codeception - SunshinePHP 2016
Agility Requires Safety
Mastering Test Automation: How to Use Selenium Successfully
[AnDevCon 2016] Mutation Testing for Android
Test automation with php codeception
Testing PHP with Codeception
Efficient JavaScript Unit Testing, JavaOne China 2013
Continuous Integration Testing in Django
Drupalcamp Simpletest
Selenium RC: Automated Testing of Modern Web Applications
Trust Your Pipeline - Automatically Testing and End-to-End Java Application
Introduction To Eclipse RCP
Selenium Interview Questions And Answers | Selenium Interview Questions | Sel...
API Testing with Open Source Code and Cucumber
Selenium basic
PhoneGap JavaScript API vs Native Components
Selenium Interview Questions and Answers For Freshers And Experienced | Edureka
React a11y-csun
Ad

Similar to So You Just Inherited a $Legacy Application... (20)

PDF
Throwing Laravel into your Legacy App™
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
The bigrewrite
PDF
Test driven development - Zombie proof your code
PDF
Developing sustainable php projects
PPTX
The bigrewrite
PDF
Brutal refactoring, lying code, the Churn, and other emotional stories from L...
PDF
From dev to ops and beyond - getting it done
PDF
Refactoring Legacy Code
PDF
Your code are my tests
PPTX
Novelty in Non-Greenfield
PDF
Workshop: Refactoring Legacy PHP: The Complete Guide
PDF
The rocket internet experience @ PHP.TO.START 2013 in Turin
PDF
Introducing TDD to your project
PPTX
Continuous feature-development
PDF
Modernizing Legacy Applications in PHP, por Paul Jones
PDF
Living With Legacy Code
KEY
PHP Industrialization
Throwing Laravel into your Legacy App™
Reduce Reuse Refactor
Code Coverage for Total Security in Application Migrations
PHP 4? OMG! A small vademecum for obsolete software migration.
The bigrewrite
Test driven development - Zombie proof your code
Developing sustainable php projects
The bigrewrite
Brutal refactoring, lying code, the Churn, and other emotional stories from L...
From dev to ops and beyond - getting it done
Refactoring Legacy Code
Your code are my tests
Novelty in Non-Greenfield
Workshop: Refactoring Legacy PHP: The Complete Guide
The rocket internet experience @ PHP.TO.START 2013 in Turin
Introducing TDD to your project
Continuous feature-development
Modernizing Legacy Applications in PHP, por Paul Jones
Living With Legacy Code
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
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
PDF
Acceptance & Functional Testing with Codeception - 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 $$
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
Acceptance & Functional Testing with Codeception - Devspace 2015

Recently uploaded (20)

PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
OOP with Java - Java Introduction (Basics)
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
Geodesy 1.pptx...............................................
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
Digital Logic Computer Design lecture notes
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PPTX
Welding lecture in detail for understanding
PDF
Well-logging-methods_new................
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
OOP with Java - Java Introduction (Basics)
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Geodesy 1.pptx...............................................
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
CYBER-CRIMES AND SECURITY A guide to understanding
Digital Logic Computer Design lecture notes
Lesson 3_Tessellation.pptx finite Mathematics
Welding lecture in detail for understanding
Well-logging-methods_new................
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...

So You Just Inherited a $Legacy Application...