SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Working Effectively with
  Legacy Code
                     Roberto Hernandez-Pou
                     Managing Consultant
                     Excella Consulting
                     @hernandezrobert
                     http://www.overridethis.com



Excella Consulting – http://www.excella.com
Legacy Code: Characteristics

•    Poor Architecture
•    Non-Uniform coding styles
•    Poor or Non-Existing Documentation
•    Mythical “Oral” Documentation
•    No Tests (or Minimal Test Coverage)
• Extremely Valuable!
       – Only Successful code becomes Legacy Code.




Excella Consulting – http://www.excella.com                                  #DCAEC12   @HernandezRobert
* Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
Agenda

•    How does code become Legacy Code?
•    Reasons to work with Legacy Code
•    What are my options?
•    How do we approach the work?
       – Edit and Pray „or‟ Cover and Modify
•    The Legacy Code Change Algorithm
•    Sensing and Separation
•    Fake Collaborators
•    Seams
•    Tools
•    TDD for Legacy Code


Excella Consulting – http://www.excella.com                                  #DCAEC12   @HernandezRobert
* Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
How does code become Legacy Code?

• New Features or New Requirements
       – Developers usually turn to shortcuts and hacks to make deadlines
         and deliver on time to market.


• Software Team Turnover or Large Development Teams
       – Multiple styles of coding.
       – Lack of vision.
       – Code duplication.


• Poor Team Communication.



Excella Consulting – http://www.excella.com                                  #DCAEC12   @HernandezRobert
* Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
Reasons to “Work with Legacy Code”

• Four reasons to change software:
       –   Adding a feature
       –   Fixing a bug
       –   Refactoring
       –   Optimizing resource usage
                               Adding a Feature         Fixing a Bug         Refactoring     Optimizing
                                                                                           resource usage
    Structure                       Changes               Changes                Changes

    New Functionality               Changes

    Functionality                                         Changes

    Resource Usage                                                                            Changes


Excella Consulting – http://www.excella.com                                  #DCAEC12       @HernandezRobert
* Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
As a Developer what are my options?

• Look for a new Job?
• Start from scratch.
       – Big bang approach!
• Have somebody else do the job:
       – Members of the original development team
       – Consultants ($$$)

• Deal with it!


Excella Consulting – http://www.excella.com                                  #DCAEC12   @HernandezRobert
* Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
How do we approach the work?

• Working with Feedback
       – Edit and pray
          (Industry standard)

       – Cover and modify




Excella Consulting – http://www.excella.com                                  #DCAEC12   @HernandezRobert
* Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
Edit and Pray

•   Carefully plan the changes
•   Make sure you understand the code
•   Start making changes
•   Poke around to see if you broke anything
•   Deploy to production environment
•   Wait for feedback from customers
Cover and Modify

• Build a safety net (Covering = Testing)
• Unit Testing
• Higher level testing


                                   The Legacy Code Dilemma
                      When we change code, we should have tests in place.
                         To put tests in place we need to change code




Excella Consulting – http://www.excella.com                                  #DCAEC12   @HernandezRobert
* Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
Cover and Modify

• Introduce Unit Tests

• Unit Tests are:
       –   Fast
       –   Localise Problems
       –   Do not talk to a database
       –   Do not communicate over the network
       –   Do not communicate with local resources
       –   Do not need config changes




Excella Consulting – http://www.excella.com                                  #DCAEC12   @HernandezRobert
* Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
The Legacy Code Change Algorithm

    Identify change points
    Find test points
    Break dependencies
    Write tests
    Make changes and refactor




Excella Consulting – http://www.excella.com                                  #DCAEC12   @HernandezRobert
* Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
Sensing & Separation


• Sensing: we break dependencies to sense when we can't access
  values our code computes

• Separation: we break dependencies to separate when we can't
  even get a piece of code into a test harness to run




Excella Consulting – http://www.excella.com                                  #DCAEC12   @HernandezRobert
* Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
Fake Collaborators

• Object that impersonates some collaborator of your class when its
  being tested.
       – Demo: Echo Console




Excella Consulting – http://www.excella.com                                  #DCAEC12   @HernandezRobert
* Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
The Seam Model

• Seam: a place where you can alter behavior of your program
  without editing in that place.
• Enabling Point: Every seam has an enabling point, a place where
  you can make the decision to use one behavior or another.

• Looking for existing seams in legacy code allow us to break
  dependencies (for sensing or separation) without refactoring.

• Demo: Echo Console
• Demo: Fake Data Reader


Excella Consulting – http://www.excella.com                                  #DCAEC12   @HernandezRobert
* Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
Tools




Excella Consulting – http://www.excella.com                                  #DCAEC12   @HernandezRobert
* Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
Test Driven Development

• Test-Driven Development (TDD)

       1. Write a failing test
       2. Get it to compile
       3. Make it pass
       4. Remove duplication
       5. Repeat


• Programming by difference




Excella Consulting – http://www.excella.com                                  #DCAEC12   @HernandezRobert
* Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
Test Driven Development

• Test-Driven Development (TDD) for legacy

       0. Get the class you want to change under test
       1. Write a failing test
       2. Get it to compile
       3. Make it pass (try not to change existing code)
       4. Remove duplication
       5. Repeat


• Programming by difference



Excella Consulting – http://www.excella.com                                  #DCAEC12   @HernandezRobert
* Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
Conclusions

• No “silver bullet” here, it's hard work but not impossible
• Overwhelming at first but things will get better as the number of
  tests increase
• Be pragmatic!
Resources


           “Working Effectively with Legacy Code” by
   1.
           Michael Feathers

   2.      http://www.objectmentor.com

   3.      http://www.overridethis.com

           http://bitbucket.org/rhp_74/overridethis.legacycode
   4.
           sample

Excella Consulting – http://www.excella.com
Thank You!


   1.      Blog: http://www.overridethis.com

   2.      Email: roberto.hernandez@excella.com

   3.      @hernandezrobert

   4.


Excella Consulting – http://www.excella.com

Weitere ähnliche Inhalte

Andere mochten auch

чужинова нв, шляхтина он
чужинова нв, шляхтина ончужинова нв, шляхтина он
чужинова нв, шляхтина онchuginova
 
Destiny’s christmas speech
Destiny’s christmas speechDestiny’s christmas speech
Destiny’s christmas speechslrussell1
 
Scatol8 UUDD livello A_2
Scatol8 UUDD livello A_2Scatol8 UUDD livello A_2
Scatol8 UUDD livello A_2Scatol8
 
自己的遊戲自己寫 - 立志中學 2014/12/1 遊戲設計分享簡報
自己的遊戲自己寫 - 立志中學 2014/12/1 遊戲設計分享簡報自己的遊戲自己寫 - 立志中學 2014/12/1 遊戲設計分享簡報
自己的遊戲自己寫 - 立志中學 2014/12/1 遊戲設計分享簡報Mac Taylor
 
عرض الدرعية
عرض الدرعيةعرض الدرعية
عرض الدرعيةMHSEN_46
 
Coffee Shop Security Group Tool
Coffee Shop Security Group ToolCoffee Shop Security Group Tool
Coffee Shop Security Group Tooljoehack3r
 
[CLP] IT industry Day 2 - 4
[CLP] IT industry  Day 2 - 4[CLP] IT industry  Day 2 - 4
[CLP] IT industry Day 2 - 4Junhyuk Lee
 
Discover the power to be truly
Discover the power to be trulyDiscover the power to be truly
Discover the power to be trulytreasure4me
 
Presentatie VOV- retentie
Presentatie VOV- retentiePresentatie VOV- retentie
Presentatie VOV- retentieAerts_Sabine
 
Larry Logan Live Webinar: Winning Customer Loyalty Through Digitally Empowere...
Larry Logan Live Webinar: Winning Customer Loyalty Through Digitally Empowere...Larry Logan Live Webinar: Winning Customer Loyalty Through Digitally Empowere...
Larry Logan Live Webinar: Winning Customer Loyalty Through Digitally Empowere...SGK
 
Teorías de la Psicología Educativa
 Teorías de la Psicología Educativa Teorías de la Psicología Educativa
Teorías de la Psicología EducativaMoniTa Rei
 

Andere mochten auch (20)

чужинова нв, шляхтина он
чужинова нв, шляхтина ончужинова нв, шляхтина он
чужинова нв, шляхтина он
 
Destiny’s christmas speech
Destiny’s christmas speechDestiny’s christmas speech
Destiny’s christmas speech
 
Scatol8 UUDD livello A_2
Scatol8 UUDD livello A_2Scatol8 UUDD livello A_2
Scatol8 UUDD livello A_2
 
自己的遊戲自己寫 - 立志中學 2014/12/1 遊戲設計分享簡報
自己的遊戲自己寫 - 立志中學 2014/12/1 遊戲設計分享簡報自己的遊戲自己寫 - 立志中學 2014/12/1 遊戲設計分享簡報
自己的遊戲自己寫 - 立志中學 2014/12/1 遊戲設計分享簡報
 
svt
svtsvt
svt
 
عرض الدرعية
عرض الدرعيةعرض الدرعية
عرض الدرعية
 
math
mathmath
math
 
Tmđt
TmđtTmđt
Tmđt
 
La crudelta
La crudeltaLa crudelta
La crudelta
 
svt2
svt2svt2
svt2
 
Coffee Shop Security Group Tool
Coffee Shop Security Group ToolCoffee Shop Security Group Tool
Coffee Shop Security Group Tool
 
[CLP] IT industry Day 2 - 4
[CLP] IT industry  Day 2 - 4[CLP] IT industry  Day 2 - 4
[CLP] IT industry Day 2 - 4
 
Discover the power to be truly
Discover the power to be trulyDiscover the power to be truly
Discover the power to be truly
 
Presentatie VOV- retentie
Presentatie VOV- retentiePresentatie VOV- retentie
Presentatie VOV- retentie
 
Feliz dia del maestro.pptx rr
Feliz dia del maestro.pptx rrFeliz dia del maestro.pptx rr
Feliz dia del maestro.pptx rr
 
Villast longani
Villast longaniVillast longani
Villast longani
 
Larry Logan Live Webinar: Winning Customer Loyalty Through Digitally Empowere...
Larry Logan Live Webinar: Winning Customer Loyalty Through Digitally Empowere...Larry Logan Live Webinar: Winning Customer Loyalty Through Digitally Empowere...
Larry Logan Live Webinar: Winning Customer Loyalty Through Digitally Empowere...
 
Employment Testing in HRM.
Employment Testing in HRM.Employment Testing in HRM.
Employment Testing in HRM.
 
Teorías de la Psicología Educativa
 Teorías de la Psicología Educativa Teorías de la Psicología Educativa
Teorías de la Psicología Educativa
 
Trabajo grupal
Trabajo grupalTrabajo grupal
Trabajo grupal
 

Ähnlich wie Working with Legacy Code

Ekon20 mORMot Legacy Code Technical Debt Delphi Conference
Ekon20 mORMot Legacy Code Technical Debt Delphi Conference Ekon20 mORMot Legacy Code Technical Debt Delphi Conference
Ekon20 mORMot Legacy Code Technical Debt Delphi Conference Arnaud Bouchez
 
Create Your Own Starter Files
Create Your Own Starter FilesCreate Your Own Starter Files
Create Your Own Starter FilesEmily Lewis
 
Agile, Automated, Aware: How to Model for Success
Agile, Automated, Aware: How to Model for SuccessAgile, Automated, Aware: How to Model for Success
Agile, Automated, Aware: How to Model for SuccessInside Analysis
 
SE2016 Java Alex Theedom "Java EE revisits design patterns"
SE2016 Java Alex Theedom "Java EE revisits design patterns"SE2016 Java Alex Theedom "Java EE revisits design patterns"
SE2016 Java Alex Theedom "Java EE revisits design patterns"Inhacking
 
14 Habits of Great SQL Developers
14 Habits of Great SQL Developers14 Habits of Great SQL Developers
14 Habits of Great SQL DevelopersIke Ellis
 
Data Modeling for NoSQL
Data Modeling for NoSQLData Modeling for NoSQL
Data Modeling for NoSQLTony Tam
 
How to guarantee your change is integrated to Moodle core
How to guarantee your change is integrated to Moodle coreHow to guarantee your change is integrated to Moodle core
How to guarantee your change is integrated to Moodle coreDan Poltawski
 
TDD and the Legacy Code Black Hole
TDD and the Legacy Code Black HoleTDD and the Legacy Code Black Hole
TDD and the Legacy Code Black HoleNoam Kfir
 
14 Habits of Great SQL Developers
14 Habits of Great SQL Developers14 Habits of Great SQL Developers
14 Habits of Great SQL DevelopersIke Ellis
 
Intelligent content and Flare
Intelligent content and Flare Intelligent content and Flare
Intelligent content and Flare Denise Kadilak
 
Art of refactoring - Code Smells and Microservices Antipatterns
Art of refactoring - Code Smells and Microservices AntipatternsArt of refactoring - Code Smells and Microservices Antipatterns
Art of refactoring - Code Smells and Microservices AntipatternsEl Mahdi Benzekri
 
Puppet Camp Austin 2015: Getting Started with Puppet
Puppet Camp Austin 2015: Getting Started with PuppetPuppet Camp Austin 2015: Getting Started with Puppet
Puppet Camp Austin 2015: Getting Started with PuppetPuppet
 
SE2016 - Java EE revisits design patterns 2016
SE2016 - Java EE revisits design patterns 2016SE2016 - Java EE revisits design patterns 2016
SE2016 - Java EE revisits design patterns 2016Alex Theedom
 
Building a Collaborative Data Architecture
Building a Collaborative Data ArchitectureBuilding a Collaborative Data Architecture
Building a Collaborative Data ArchitectureDATAVERSITY
 
4 roles on the it project team
4 roles on the it project team4 roles on the it project team
4 roles on the it project teamDaniel Gordon
 
Clean code presentation
Clean code presentationClean code presentation
Clean code presentationBhavin Gandhi
 
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018Mike Harris
 

Ähnlich wie Working with Legacy Code (20)

Ekon20 mORMot Legacy Code Technical Debt Delphi Conference
Ekon20 mORMot Legacy Code Technical Debt Delphi Conference Ekon20 mORMot Legacy Code Technical Debt Delphi Conference
Ekon20 mORMot Legacy Code Technical Debt Delphi Conference
 
Create Your Own Starter Files
Create Your Own Starter FilesCreate Your Own Starter Files
Create Your Own Starter Files
 
Agile, Automated, Aware: How to Model for Success
Agile, Automated, Aware: How to Model for SuccessAgile, Automated, Aware: How to Model for Success
Agile, Automated, Aware: How to Model for Success
 
Eurosport's Kodakademi #2
Eurosport's Kodakademi #2Eurosport's Kodakademi #2
Eurosport's Kodakademi #2
 
Top 10 Reasons to Switch to ER/Studio
Top 10 Reasons to Switch to ER/Studio Top 10 Reasons to Switch to ER/Studio
Top 10 Reasons to Switch to ER/Studio
 
Alex Theedom Java ee revisits design patterns
Alex Theedom	Java ee revisits design patternsAlex Theedom	Java ee revisits design patterns
Alex Theedom Java ee revisits design patterns
 
SE2016 Java Alex Theedom "Java EE revisits design patterns"
SE2016 Java Alex Theedom "Java EE revisits design patterns"SE2016 Java Alex Theedom "Java EE revisits design patterns"
SE2016 Java Alex Theedom "Java EE revisits design patterns"
 
14 Habits of Great SQL Developers
14 Habits of Great SQL Developers14 Habits of Great SQL Developers
14 Habits of Great SQL Developers
 
Data Modeling for NoSQL
Data Modeling for NoSQLData Modeling for NoSQL
Data Modeling for NoSQL
 
How to guarantee your change is integrated to Moodle core
How to guarantee your change is integrated to Moodle coreHow to guarantee your change is integrated to Moodle core
How to guarantee your change is integrated to Moodle core
 
TDD and the Legacy Code Black Hole
TDD and the Legacy Code Black HoleTDD and the Legacy Code Black Hole
TDD and the Legacy Code Black Hole
 
14 Habits of Great SQL Developers
14 Habits of Great SQL Developers14 Habits of Great SQL Developers
14 Habits of Great SQL Developers
 
Intelligent content and Flare
Intelligent content and Flare Intelligent content and Flare
Intelligent content and Flare
 
Art of refactoring - Code Smells and Microservices Antipatterns
Art of refactoring - Code Smells and Microservices AntipatternsArt of refactoring - Code Smells and Microservices Antipatterns
Art of refactoring - Code Smells and Microservices Antipatterns
 
Puppet Camp Austin 2015: Getting Started with Puppet
Puppet Camp Austin 2015: Getting Started with PuppetPuppet Camp Austin 2015: Getting Started with Puppet
Puppet Camp Austin 2015: Getting Started with Puppet
 
SE2016 - Java EE revisits design patterns 2016
SE2016 - Java EE revisits design patterns 2016SE2016 - Java EE revisits design patterns 2016
SE2016 - Java EE revisits design patterns 2016
 
Building a Collaborative Data Architecture
Building a Collaborative Data ArchitectureBuilding a Collaborative Data Architecture
Building a Collaborative Data Architecture
 
4 roles on the it project team
4 roles on the it project team4 roles on the it project team
4 roles on the it project team
 
Clean code presentation
Clean code presentationClean code presentation
Clean code presentation
 
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
 

Mehr von DC Agile Engineering Conference (6)

Unindented Code Cannot Possibly Work
Unindented Code Cannot Possibly WorkUnindented Code Cannot Possibly Work
Unindented Code Cannot Possibly Work
 
Lead by Example
Lead by ExampleLead by Example
Lead by Example
 
Continuous Integration: Toolbox, Blueprint, Master Craft
Continuous Integration: Toolbox, Blueprint, Master CraftContinuous Integration: Toolbox, Blueprint, Master Craft
Continuous Integration: Toolbox, Blueprint, Master Craft
 
Continuous Delivery Applied
Continuous Delivery AppliedContinuous Delivery Applied
Continuous Delivery Applied
 
Agile Engineering and Software Craftsmanship
Agile Engineering and Software CraftsmanshipAgile Engineering and Software Craftsmanship
Agile Engineering and Software Craftsmanship
 
Improving Design through TDD
Improving Design through TDDImproving Design through TDD
Improving Design through TDD
 

Kürzlich hochgeladen

MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 

Kürzlich hochgeladen (20)

MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 

Working with Legacy Code

  • 1. Working Effectively with Legacy Code Roberto Hernandez-Pou Managing Consultant Excella Consulting @hernandezrobert http://www.overridethis.com Excella Consulting – http://www.excella.com
  • 2. Legacy Code: Characteristics • Poor Architecture • Non-Uniform coding styles • Poor or Non-Existing Documentation • Mythical “Oral” Documentation • No Tests (or Minimal Test Coverage) • Extremely Valuable! – Only Successful code becomes Legacy Code. Excella Consulting – http://www.excella.com #DCAEC12 @HernandezRobert * Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
  • 3. Agenda • How does code become Legacy Code? • Reasons to work with Legacy Code • What are my options? • How do we approach the work? – Edit and Pray „or‟ Cover and Modify • The Legacy Code Change Algorithm • Sensing and Separation • Fake Collaborators • Seams • Tools • TDD for Legacy Code Excella Consulting – http://www.excella.com #DCAEC12 @HernandezRobert * Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
  • 4. How does code become Legacy Code? • New Features or New Requirements – Developers usually turn to shortcuts and hacks to make deadlines and deliver on time to market. • Software Team Turnover or Large Development Teams – Multiple styles of coding. – Lack of vision. – Code duplication. • Poor Team Communication. Excella Consulting – http://www.excella.com #DCAEC12 @HernandezRobert * Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
  • 5. Reasons to “Work with Legacy Code” • Four reasons to change software: – Adding a feature – Fixing a bug – Refactoring – Optimizing resource usage Adding a Feature Fixing a Bug Refactoring Optimizing resource usage Structure Changes Changes Changes New Functionality Changes Functionality Changes Resource Usage Changes Excella Consulting – http://www.excella.com #DCAEC12 @HernandezRobert * Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
  • 6. As a Developer what are my options? • Look for a new Job? • Start from scratch. – Big bang approach! • Have somebody else do the job: – Members of the original development team – Consultants ($$$) • Deal with it! Excella Consulting – http://www.excella.com #DCAEC12 @HernandezRobert * Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
  • 7. How do we approach the work? • Working with Feedback – Edit and pray (Industry standard) – Cover and modify Excella Consulting – http://www.excella.com #DCAEC12 @HernandezRobert * Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
  • 8. Edit and Pray • Carefully plan the changes • Make sure you understand the code • Start making changes • Poke around to see if you broke anything • Deploy to production environment • Wait for feedback from customers
  • 9. Cover and Modify • Build a safety net (Covering = Testing) • Unit Testing • Higher level testing The Legacy Code Dilemma When we change code, we should have tests in place. To put tests in place we need to change code Excella Consulting – http://www.excella.com #DCAEC12 @HernandezRobert * Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
  • 10. Cover and Modify • Introduce Unit Tests • Unit Tests are: – Fast – Localise Problems – Do not talk to a database – Do not communicate over the network – Do not communicate with local resources – Do not need config changes Excella Consulting – http://www.excella.com #DCAEC12 @HernandezRobert * Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
  • 11. The Legacy Code Change Algorithm  Identify change points  Find test points  Break dependencies  Write tests  Make changes and refactor Excella Consulting – http://www.excella.com #DCAEC12 @HernandezRobert * Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
  • 12. Sensing & Separation • Sensing: we break dependencies to sense when we can't access values our code computes • Separation: we break dependencies to separate when we can't even get a piece of code into a test harness to run Excella Consulting – http://www.excella.com #DCAEC12 @HernandezRobert * Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
  • 13. Fake Collaborators • Object that impersonates some collaborator of your class when its being tested. – Demo: Echo Console Excella Consulting – http://www.excella.com #DCAEC12 @HernandezRobert * Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
  • 14. The Seam Model • Seam: a place where you can alter behavior of your program without editing in that place. • Enabling Point: Every seam has an enabling point, a place where you can make the decision to use one behavior or another. • Looking for existing seams in legacy code allow us to break dependencies (for sensing or separation) without refactoring. • Demo: Echo Console • Demo: Fake Data Reader Excella Consulting – http://www.excella.com #DCAEC12 @HernandezRobert * Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
  • 15. Tools Excella Consulting – http://www.excella.com #DCAEC12 @HernandezRobert * Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
  • 16. Test Driven Development • Test-Driven Development (TDD) 1. Write a failing test 2. Get it to compile 3. Make it pass 4. Remove duplication 5. Repeat • Programming by difference Excella Consulting – http://www.excella.com #DCAEC12 @HernandezRobert * Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
  • 17. Test Driven Development • Test-Driven Development (TDD) for legacy 0. Get the class you want to change under test 1. Write a failing test 2. Get it to compile 3. Make it pass (try not to change existing code) 4. Remove duplication 5. Repeat • Programming by difference Excella Consulting – http://www.excella.com #DCAEC12 @HernandezRobert * Based on the Book “Working Effectively with Legacy Code” by Michael Feathers
  • 18. Conclusions • No “silver bullet” here, it's hard work but not impossible • Overwhelming at first but things will get better as the number of tests increase • Be pragmatic!
  • 19. Resources “Working Effectively with Legacy Code” by 1. Michael Feathers 2. http://www.objectmentor.com 3. http://www.overridethis.com http://bitbucket.org/rhp_74/overridethis.legacycode 4. sample Excella Consulting – http://www.excella.com
  • 20. Thank You! 1. Blog: http://www.overridethis.com 2. Email: roberto.hernandez@excella.com 3. @hernandezrobert 4. Excella Consulting – http://www.excella.com