Release Your Refactoring Superpower By: Adam Culp Twitter: @adamculp

Release Your Refactoring Superpower About me ● – OSS Contributor – PHP Certified – Zend Certification Advisory Board – PHP-Fig voting member (IBM i Toolkit) – Consultant at Zend Technologies – Organizer SoFloPHP (South Florida) – Organizer SunshinePHP (Miami) – Long distance (ultra) runner – Photography Enthusiast – 2 Judo Black Belt Instructor

Release Your Refactoring Superpower About me ● – OSS Contributor – PHP Certified – Zend Certification Advisory Board – PHP-Fig voting member (IBM i Toolkit) – Consultant at Zend Technologies – Organizer SoFloPHP (South Florida) – Organizer SunshinePHP (Miami) – Long distance (ultra) runner – – 3 I am the Photography Enthusiast PHP Ninja!!! Judo Black Belt Instructor

Release Your Refactoring Superpower ● Fan of iteration – 4 Pretty much everything requires iteration to do well: ● Long distance running ● Judo ● Development ● Evading project managers ● Refactoring!

Release Your Refactoring Superpower ● What Can I Do? – 5 Estimation

Release Your Refactoring Superpower ● 6 What Can I Do? – Estimation – Coding (actual refactoring)

Release Your Refactoring Superpower ● 7 What Can I Do? – Estimation – Coding (actual refactoring) – Algorithms

Release Your Refactoring Superpower ● 8 What Can I Do? – Estimation – Coding (actual refactoring) – Algorithms – Convince Business

Release Your Refactoring Superpower ● 9 What Can I Do? – Estimation – Coding (actual refactoring) – Algorithms – Convince Business – Silver Bullet

Release Your Refactoring Superpower ● Modernization? – How? ● 10 New infrastructure (servers, technology, etc.)

Release Your Refactoring Superpower ● Modernization? – 11 How? ● New infrastructure (servers, technology, etc.) ● New frameworks or libraries

Release Your Refactoring Superpower ● Modernization? – 12 How? ● New infrastructure (servers, technology, etc.) ● New frameworks or libraries ● New programming language

Release Your Refactoring Superpower ● Modernization? – 13 How? ● New infrastructure (servers, technology, etc.) ● New frameworks or libraries ● New programming language ● New DB

Release Your Refactoring Superpower ● Modernization? – – How? ● New infrastructure (servers, technology, etc.) ● New frameworks or libraries ● New programming language ● New DB Why? ● 14 Desire

Release Your Refactoring Superpower ● Modernization? – – 15 How? ● New infrastructure (servers, technology, etc.) ● New frameworks or libraries ● New programming language ● New DB Why? ● Desire ● Bored

Release Your Refactoring Superpower ● Modernization? – – 16 How? ● New infrastructure (servers, technology, etc.) ● New frameworks or libraries ● New programming language ● New DB Why? ● Desire ● Bored ● Perceived need

Release Your Refactoring Superpower ● Modernization? – – 17 How? ● New infrastructure (servers, technology, etc.) ● New frameworks or libraries ● New programming language ● New DB Why? ● Desire ● Bored ● Perceived need ● To gain something – Speed – Functionality

Release Your Refactoring Superpower ● Modernization? – – – How? ● New infrastructure (servers, technology, etc.) ● New frameworks or libraries ● New programming language ● New DB Why? ● Desire ● Bored ● Perceived need ● To gain something Speed – Functionality When? ● 18 – Next 6 months, year(s), decade

Release Your Refactoring Superpower ● Modernization? – – – 19 How? ● New infrastructure (servers, technology, etc.) ● New frameworks or libraries ● New programming language ● New DB Why? ● Desire ● Bored ● Perceived need ● To gain something – Speed – Functionality When? ● Next 6 months, year(s), decade ● Realistic time

Release Your Refactoring Superpower ● Modernization? – – – 20 How? ● New infrastructure (servers, technology, etc.) ● New frameworks or libraries ● New programming language ● New DB Why? ● Desire ● Bored ● Perceived need ● To gain something – Speed – Functionality When? ● Next 6 months, year(s), decade ● Realistic time ● NOW!

Release Your Refactoring Superpower ● 21 Rewrite FTW!

Release Your Refactoring Superpower ● Typical Loop – Business Responses ● 22 No time

Release Your Refactoring Superpower ● Typical Loop – 23 Business Responses ● No time ● No money

Release Your Refactoring Superpower ● Typical Loop – 24 Business Responses ● No time ● No money ● No need

Release Your Refactoring Superpower ● Typical Loop – 25 Business Responses ● No time ● No money ● No need ● Things are “good enough”

Release Your Refactoring Superpower ● 26 The Fix

Release Your Refactoring Superpower ● Case Study – Managing legacy system costs: A case study of a meta-assessment model to identify solutions in a large financial services company – 2017 (by James Crotty, Ivan Horrocks) https://www.sciencedirect.com/science/article/pii/S221083271630126 0#b0025 ● 2001 Brooke and Ramage defined legacy as: – 27 Old information system remaining in operation within an Organization

Release Your Refactoring Superpower ● Case Study – Managing legacy system costs: A case study of a meta-assessment model to identify solutions in a large financial services company – 2017 (by James Crotty, Ivan Horrocks) https://www.sciencedirect.com/science/article/pii/S221083271630126 0#b0025 ● 28 2001 Brooke and Ramage defined legacy as: – Old information system remaining in operation within an Organization – Business critical, resisting modification as failure would cause significant impact on business

Release Your Refactoring Superpower ● Case Study – Managing legacy system costs: A case study of a meta-assessment model to identify solutions in a large financial services company – 2017 (by James Crotty, Ivan Horrocks) https://www.sciencedirect.com/science/article/pii/S221083271630126 0#b0025 ● 29 2001 Brooke and Ramage defined legacy as: – Old information system remaining in operation within an Organization – Business critical, resisting modification as failure would cause significant impact on business – Based on outdated technology but critical day-to-day operations

Release Your Refactoring Superpower ● Case Study – Managing legacy system costs: A case study of a meta-assessment model to identify solutions in a large financial services company – 2017 (by James Crotty, Ivan Horrocks) https://www.sciencedirect.com/science/article/pii/S221083271630126 0#b0025 ● 30 2001 Brooke and Ramage defined legacy as: – Old information system remaining in operation within an Organization – Business critical, resisting modification as failure would cause significant impact on business – Based on outdated technology but critical day-to-day operations – Built when processing and storage was much more expensive

Release Your Refactoring Superpower ● Case Study – Managing legacy system costs: A case study of a meta-assessment model to identify solutions in a large financial services company – 2017 (by James Crotty, Ivan Horrocks) https://www.sciencedirect.com/science/article/pii/S221083271630126 0#b0025 ● 31 2001 Brooke and Ramage defined legacy as: – Old information system remaining in operation within an Organization – Business critical, resisting modification as failure would cause significant impact on business – Based on outdated technology but critical day-to-day operations – Built when processing and storage was much more expensive – Poorly documented

Release Your Refactoring Superpower ● Case Study – Managing legacy system costs: A case study of a meta-assessment model to identify solutions in a large financial services company – 2017 (by James Crotty, Ivan Horrocks) https://www.sciencedirect.com/science/article/pii/S221083271630126 0#b0025 ● 32 2001 Brooke and Ramage defined legacy as: – Old information system remaining in operation within an Organization – Business critical, resisting modification as failure would cause significant impact on business – Based on outdated technology but critical day-to-day operations – Built when processing and storage was much more expensive – Poorly documented – Lack of design

Release Your Refactoring Superpower ● Case Study – Modernization Drivers ● 33 Skillset shortages (old technologies)

Release Your Refactoring Superpower ● Case Study – 34 Modernization Drivers ● Skillset shortages (old technologies) ● Technical needs

Release Your Refactoring Superpower ● Case Study – 35 Modernization Drivers ● Skillset shortages (old technologies) ● Technical needs ● Business needs

Release Your Refactoring Superpower ● Case Study – 36 Modernization Drivers ● Skillset shortages (old technologies) ● Technical needs ● Business needs ● Personal bias

Release Your Refactoring Superpower ● Case Study – Cost Reduction Strategies ● 37 Ordinary maintenance

Release Your Refactoring Superpower ● Case Study – 38 Cost Reduction Strategies ● Ordinary maintenance ● Reverse engineering

Release Your Refactoring Superpower ● Case Study – 39 Cost Reduction Strategies ● Ordinary maintenance ● Reverse engineering ● Restructuring

Release Your Refactoring Superpower ● Case Study – 40 Cost Reduction Strategies ● Ordinary maintenance ● Reverse engineering ● Restructuring ● Re-engineering

Release Your Refactoring Superpower ● Case Study – 41 Cost Reduction Strategies ● Ordinary maintenance ● Reverse engineering ● Restructuring ● Re-engineering ● Migration

Release Your Refactoring Superpower ● Case Study – 42 Cost Reduction Strategies ● Ordinary maintenance ● Reverse engineering ● Restructuring ● Re-engineering ● Migration ● Discard

Release Your Refactoring Superpower ● Case Study – 43 Cost Reduction Strategies ● Ordinary maintenance ● Reverse engineering ● Restructuring ● Re-engineering ● Migration ● Discard ● Wrapping

Release Your Refactoring Superpower ● Case Study – 44 Cost Reduction Strategies ● Ordinary maintenance ● Reverse engineering ● Restructuring ● Re-engineering ● Migration ● Discard ● Wrapping ● Outsource?

Release Your Refactoring Superpower ● Case Study – 45 Cost Reduction Strategies ● Ordinary maintenance ● Reverse engineering ● Restructuring ● Re-engineering ● Migration ● Discard ● Wrapping ● Outsource? ● Freeze

Release Your Refactoring Superpower ● Case Study – 46 Cost Reduction Strategies ● Ordinary maintenance ● Reverse engineering ● Restructuring ● Re-engineering ● Migration ● Discard ● Wrapping ● Outsource? ● Freeze ● Carry On

Release Your Refactoring Superpower ● Case Study – 47 Cost Reduction Strategies ● Ordinary maintenance ● Reverse engineering ● Restructuring ● Re-engineering ● Migration ● Discard ● Wrapping ● Outsource? ● Freeze ● Carry On ● Replacement with commercial off-the-shelf software and discarding

Release Your Refactoring Superpower ● How Do We Know? – Measurement ● A Method for Assessing Legacy Systems for Evolution – 1998 (by Jane Ransom, Ian Sommerville, and Ian Warren) http://citeseerx.ist.psu.edu/viewdoc/download? doi=10.1.1.128.9889&rep=rep1&type=pdf – 48 Legacy = business critical = cost not justifiable

Release Your Refactoring Superpower ● How Do We Know? – Measurement ● 49 A Method for Assessing Legacy Systems for Evolution – 1998 (by Jane Ransom, Ian Sommerville, and Ian Warren) http://citeseerx.ist.psu.edu/viewdoc/download? doi=10.1.1.128.9889&rep=rep1&type=pdf – Legacy = business critical = cost not justifiable – Company and project specific

Release Your Refactoring Superpower ● How Do We Know? – Measurement ● 50 A Method for Assessing Legacy Systems for Evolution – 1998 (by Jane Ransom, Ian Sommerville, and Ian Warren) http://citeseerx.ist.psu.edu/viewdoc/download? doi=10.1.1.128.9889&rep=rep1&type=pdf – Legacy = business critical = cost not justifiable – Company and project specific – Continuously refined

Release Your Refactoring Superpower ● How Do We Know? – Measurement ● 51 A Method for Assessing Legacy Systems for Evolution – 1998 (by Jane Ransom, Ian Sommerville, and Ian Warren) http://citeseerx.ist.psu.edu/viewdoc/download? doi=10.1.1.128.9889&rep=rep1&type=pdf – Legacy = business critical = cost not justifiable – Company and project specific – Continuously refined – Gains depth of understanding of business

Release Your Refactoring Superpower ● How Do We Know? – Criteria ● Decision Model for Legacy Systems - 1999 (by . H. Bennett, M. Ramage, and M. Munro) - ftp://ftp.inf.pucrio.br/pub/docs/FomularioSolicitacoes/mariliaGFerreira-09-13-7.pdf – Based more upon organizational points ● 52 Boundary: the unit of analysis

Release Your Refactoring Superpower ● How Do We Know? – Criteria ● Decision Model for Legacy Systems - 1999 (by . H. Bennett, M. Ramage, and M. Munro) - ftp://ftp.inf.pucrio.br/pub/docs/FomularioSolicitacoes/mariliaGFerreira-09-13-7.pdf – Based more upon organizational points ● ● 53 Boundary: the unit of analysis Vision: global summary of the unit

Release Your Refactoring Superpower ● How Do We Know? – Criteria ● Decision Model for Legacy Systems - 1999 (by . H. Bennett, M. Ramage, and M. Munro) - ftp://ftp.inf.pucrio.br/pub/docs/FomularioSolicitacoes/mariliaGFerreira-09-13-7.pdf – Based more upon organizational points ● ● ● 54 Boundary: the unit of analysis Vision: global summary of the unit Logic: rationale for vision

Release Your Refactoring Superpower ● How Do We Know? – Criteria ● Decision Model for Legacy Systems - 1999 (by . H. Bennett, M. Ramage, and M. Munro) - ftp://ftp.inf.pucrio.br/pub/docs/FomularioSolicitacoes/mariliaGFerreira-09-13-7.pdf – Based more upon organizational points ● ● ● ● 55 Boundary: the unit of analysis Vision: global summary of the unit Logic: rationale for vision Structure: of the organisation

Release Your Refactoring Superpower ● How Do We Know? – Criteria ● Decision Model for Legacy Systems - 1999 (by . H. Bennett, M. Ramage, and M. Munro) - ftp://ftp.inf.pucrio.br/pub/docs/FomularioSolicitacoes/mariliaGFerreira-09-13-7.pdf – Based more upon organizational points ● ● ● ● ● 56 Boundary: the unit of analysis Vision: global summary of the unit Logic: rationale for vision Structure: of the organisation Roles: organizational roles of people

Release Your Refactoring Superpower ● How Do We Know? – Criteria ● Decision Model for Legacy Systems - 1999 (by . H. Bennett, M. Ramage, and M. Munro) - ftp://ftp.inf.pucrio.br/pub/docs/FomularioSolicitacoes/mariliaGFerreira-09-13-7.pdf – Based more upon organizational points ● ● ● ● ● ● 57 Boundary: the unit of analysis Vision: global summary of the unit Logic: rationale for vision Structure: of the organisation Roles: organizational roles of people View of information: resource analysis

Release Your Refactoring Superpower ● How Do We Know? – Criteria ● Decision Model for Legacy Systems - 1999 (by . H. Bennett, M. Ramage, and M. Munro) - ftp://ftp.inf.pucrio.br/pub/docs/FomularioSolicitacoes/mariliaGFerreira-09-13-7.pdf – Based more upon organizational points ● ● ● ● ● ● ● 58 Boundary: the unit of analysis Vision: global summary of the unit Logic: rationale for vision Structure: of the organisation Roles: organizational roles of people View of information: resource analysis Costs: major costs, both financial and nonfinancial

Release Your Refactoring Superpower ● How Do We Know? – Criteria ● Decision Model for Legacy Systems - 1999 (by . H. Bennett, M. Ramage, and M. Munro) - ftp://ftp.inf.pucrio.br/pub/docs/FomularioSolicitacoes/mariliaGFerreira-09-13-7.pdf – Based more upon organizational points ● ● ● ● ● ● ● ● 59 Boundary: the unit of analysis Vision: global summary of the unit Logic: rationale for vision Structure: of the organisation Roles: organizational roles of people View of information: resource analysis Costs: major costs, both financial and nonfinancial Benefits: both financial and nonfinancial

Release Your Refactoring Superpower ● How Do We Know? – Criteria ● Decision Model for Legacy Systems - 1999 (by . H. Bennett, M. Ramage, and M. Munro) - ftp://ftp.inf.pucrio.br/pub/docs/FomularioSolicitacoes/mariliaGFerreira-09-13-7.pdf – Based more upon organizational points ● ● ● ● ● ● ● ● ● 60 Boundary: the unit of analysis Vision: global summary of the unit Logic: rationale for vision Structure: of the organisation Roles: organizational roles of people View of information: resource analysis Costs: major costs, both financial and nonfinancial Benefits: both financial and nonfinancial Risks: major sources of risk

Release Your Refactoring Superpower ● How Do We Know? – Structure ● A Framework to Assess Legacy Software Systems - 2014 (by Basem Y. Alkazemi) https://pdfs.semanticscholar.org/da50/7665a6c3bacb5559996bd436a9f76aa 4e5a7.pdf – Strategies ● 61 Replacing

Release Your Refactoring Superpower ● How Do We Know? – Structure ● A Framework to Assess Legacy Software Systems - 2014 (by Basem Y. Alkazemi) https://pdfs.semanticscholar.org/da50/7665a6c3bacb5559996bd436a9f76aa 4e5a7.pdf – Strategies ● ● 62 Replacing Maintaining

Release Your Refactoring Superpower ● How Do We Know? – Structure ● A Framework to Assess Legacy Software Systems - 2014 (by Basem Y. Alkazemi) https://pdfs.semanticscholar.org/da50/7665a6c3bacb5559996bd436a9f76aa 4e5a7.pdf – Strategies ● ● ● 63 Replacing Maintaining Re-architecting

Release Your Refactoring Superpower ● How Do We Know? – Structure ● A Framework to Assess Legacy Software Systems - 2014 (by Basem Y. Alkazemi) https://pdfs.semanticscholar.org/da50/7665a6c3bacb5559996bd436a9f76aa 4e5a7.pdf – Strategies ● ● ● ● 64 Replacing Maintaining Re-architecting Extending by wrapping

Release Your Refactoring Superpower ● How Do We Know? – Application ● A Decisional Framework to Measure System Dimensions of Legacy Application for Rejuvenation through Reengineering - 2011 (by Er. Anand Rajavat, Dr. (Mrs.) Vrinda Tokekar) https://www.ijcaonline.org/volume16/number2/pxc3872674.pdf – System domain ● ● ● ● 65 Customer requirements Orgs strategic goals Operational env Risk management i. Organizational ii. Resource iii.Development iv.Personal v. User Requirement vi.Specialization vii.Team viii.Communication

Release Your Refactoring Superpower

66

Release Your Refactoring Superpower

67

Release Your Refactoring Superpower ● Case Study – 68 Example Assessment ● Step #1 - Does application meet or exceed definition of “Legacy”? ● Answers: Yes, No, Maybe, Don’t know – Business Critical – Old – Changed to meet organizational needs – Degrades as changes made – Maintenance cost increase as changes made – Obsolete languages – Poor, if any, documentation – Inadequate data management – Limited support capability – Limited support capacity – Lacks architecture to evolve to meet emerging requirements

Release Your Refactoring Superpower ● Case Study – Example Assessment ● Step #1 – Technical value attribute assessment ● Answers: Yes, No, Don’t know – Maintainability ● ● ● ● – Decompostability/Architecture ● ● ● ● ● ● 69 LOC Control Flow Cyclomatic complexity Dead code fate Modularity % of modules with separation of concerns Consumption Extensibility Style Interoperability

Release Your Refactoring Superpower ● Case Study – Example Assessment ● Step #1 – Cont’d ● Answers: Yes, No, Don’t know – Deterioration ● ● ● ● – Obsolescence ● ● ● ● ● ● ● 70 Backlog increase Defect rate increase Response-time increase Maintanance time per request increase System age Operating system version Hardware version Technical support availability Security Legality System evolution required for business goals?

Release Your Refactoring Superpower ● Case Study – Example Assessment ● Step #2 – Business value attribute assessment ● Answers: Yes, No, Don’t know – Economic value ● ● ● – Data value ● ● – ● ● Business function coverage rate Actual usage frequency Customer/user satisfaction metric Specialization ● ● 71 % of mission critical archives % of application dependent archives Utility ● – Market value Profitability index IRR % of highly specialized functions % of generic functions

Release Your Refactoring Superpower ● Case Study – 72 Example Assessment ● Step #3 – Organizational infrastructure attribute assessment ● Answers: Yes, No, Don’t know – Development & maintenance internal or outsourced? – Technical maturity – Commitment to training – Skill level of system support – Response to change

Release Your Refactoring Superpower ● Case Study – Example Assessment ● 73 Step #4 – Calculations – Calculate all responses to 1 – 5 values (don’t know = 0) – To easily plot on decisional matrix

Release Your Refactoring Superpower ● Case Study – Example Assessment ● Step #5 – Conversion – 74 Convert Y, N, DK to numeric values and Avg %

Release Your Refactoring Superpower ● Case Study – Example Assessment ● Step #6 – Plotting – 75 Display points on the decisional matrix

Release Your Refactoring Superpower ● Superhero – Status Granted ● 76 It’s YOU!

Release Your Refactoring Superpower ● Supervillain – Professor LOC ● 77 Fighting tools – PHPLoc – PHPmd (codesize)

Release Your Refactoring Superpower ● The Data – 78 PHPLoc

Release Your Refactoring Superpower ● The Data – 79 PHPmd

Release Your Refactoring Superpower ● Ray Gun – 80 Docker Images

Release Your Refactoring Superpower ● Arsenal – 81 1 million commits ● Rename Variable/Method/Class 77% ● Extract Constant ● Make Type Global ● Rename Refactoring Command ● Move/Extract Class 1% ● Move/Extract Method 13% ● Modify Method Parameters

● Thank you! – Code: https://github.com/adamculp/ Adam Culp http://www.geekyboy.com http://RunGeekRadio.com Twitter @adamculp Questions?