Working Effectively with Legacy Code (draft)

Andrea Francia
Andrea FranciaFull Stack Something at 7Pixel S.r.l.
Working Effectively with Legacy Code  written by Michael Feathers Something I understand about the book
Contents ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The Book ,[object Object],[object Object],http://www.amazon.com/Working-Effectively-Legacy-Michael-Feathers/dp/0131177052   Paperback:  456 pages Publisher:  Prentice Hall PTR; 1 edition (October 2, 2004)
What is legacy code? (for me/us?) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What is legacy code? (M.Feathers) ,[object Object],[object Object],[object Object]
The conservative approach ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],If it ain't broke don't fix it
Preserving Behaviour with Characterization Tests  ,[object Object],[object Object],[object Object],Please note that: “actual” is not always the same as “correct”.
Characterization Tests Example (1/5) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Characterization  Tests Example (2/5) ,[object Object],[object Object],[object Object],[object Object],Testcase: testSlaDjcl(prova.ProvaTest):  FAILED array lengths differed, expected.length=0 actual.length=3 junit.framework.AssertionFailedError: array lengths differed, expected.length=0 actual.length=3 at prova.ProvaTest.testSlaDjcl(ProvaTest.java:19)
Characterization  Tests Example (3/5) ,[object Object],[object Object],[object Object],[object Object],Testcase: testSlaDjcl(prova.ProvaTest):  Caused an ERROR arrays first differed at element [0]; expected:<0> but was:<1858> arrays first differed at element [0]; expected:<0> but was:<1858> at prova.ProvaTest.testSlaDjcl(ProvaTest.java:19)
Characterization  Tests Example (4/5) ,[object Object],[object Object],[object Object],[object Object],BUILD SUCCESSFUL (total time: 0 seconds)
Characterization  Tests Example (5/5) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The TDD algorithm ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Conclusions: Complaints / Solutions matrix So then you ... But legacy code… add them (as characterization tests) lacks of test redesign it (with refactoring) is ugly
Conclusions: I can’t put code under tests because So you I can’t because code ,[object Object],[object Object],depends of everything ,[object Object],[object Object],lacks of modularity
Thanks ,[object Object],[object Object],[object Object],[object Object],[object Object]
1 of 16

Recommended

Testers guide to unit testing by
Testers guide to unit testingTesters guide to unit testing
Testers guide to unit testingCraig Risi
98 views34 slides
Test Driven Development: Why I hate it; but secretly love it. by
Test Driven Development: Why I hate it; but secretly love it. Test Driven Development: Why I hate it; but secretly love it.
Test Driven Development: Why I hate it; but secretly love it. Tom Crinson
521 views37 slides
Developer Test - Things to Know by
Developer Test - Things to KnowDeveloper Test - Things to Know
Developer Test - Things to Knowvilniusjug
781 views108 slides
(SAC2020 SVT-2) Constrained Detecting Arrays for Fault Localization in Combin... by
(SAC2020 SVT-2) Constrained Detecting Arrays for Fault Localization in Combin...(SAC2020 SVT-2) Constrained Detecting Arrays for Fault Localization in Combin...
(SAC2020 SVT-2) Constrained Detecting Arrays for Fault Localization in Combin...Hao Jin
40 views20 slides
C++ Unit Test with Google Testing Framework by
C++ Unit Test with Google Testing FrameworkC++ Unit Test with Google Testing Framework
C++ Unit Test with Google Testing FrameworkHumberto Marchezi
7.4K views52 slides
Mutation Testing - Ruby Edition by
Mutation Testing - Ruby EditionMutation Testing - Ruby Edition
Mutation Testing - Ruby EditionChris Sinjakli
1.6K views33 slides

More Related Content

Viewers also liked

Tutti i miei sbagli, versione 7 Marzo 2012 al XPUG mi by
Tutti i miei sbagli, versione 7 Marzo 2012 al XPUG miTutti i miei sbagli, versione 7 Marzo 2012 al XPUG mi
Tutti i miei sbagli, versione 7 Marzo 2012 al XPUG miAndrea Francia
1.4K views50 slides
Piccolo coding dojo (milano xpug 2013-04-11) by
Piccolo coding dojo (milano xpug 2013-04-11)Piccolo coding dojo (milano xpug 2013-04-11)
Piccolo coding dojo (milano xpug 2013-04-11)Andrea Francia
1.2K views36 slides
Tutti i miei sbagli (Errori di un wannabe Open Source Developer) by
Tutti i miei sbagli (Errori di un wannabe Open Source Developer)Tutti i miei sbagli (Errori di un wannabe Open Source Developer)
Tutti i miei sbagli (Errori di un wannabe Open Source Developer)Andrea Francia
5.2K views148 slides
Subversion @ JUG Milano 11 dic 2009 by
Subversion @ JUG Milano 11 dic 2009Subversion @ JUG Milano 11 dic 2009
Subversion @ JUG Milano 11 dic 2009Andrea Francia
1.3K views25 slides
Introduzione al TDD by
Introduzione al TDDIntroduzione al TDD
Introduzione al TDDAndrea Francia
1.6K views65 slides
Le 12 pratiche by
Le 12 praticheLe 12 pratiche
Le 12 praticheAndrea Francia
431 views31 slides

Viewers also liked(7)

Tutti i miei sbagli, versione 7 Marzo 2012 al XPUG mi by Andrea Francia
Tutti i miei sbagli, versione 7 Marzo 2012 al XPUG miTutti i miei sbagli, versione 7 Marzo 2012 al XPUG mi
Tutti i miei sbagli, versione 7 Marzo 2012 al XPUG mi
Andrea Francia1.4K views
Piccolo coding dojo (milano xpug 2013-04-11) by Andrea Francia
Piccolo coding dojo (milano xpug 2013-04-11)Piccolo coding dojo (milano xpug 2013-04-11)
Piccolo coding dojo (milano xpug 2013-04-11)
Andrea Francia1.2K views
Tutti i miei sbagli (Errori di un wannabe Open Source Developer) by Andrea Francia
Tutti i miei sbagli (Errori di un wannabe Open Source Developer)Tutti i miei sbagli (Errori di un wannabe Open Source Developer)
Tutti i miei sbagli (Errori di un wannabe Open Source Developer)
Andrea Francia5.2K views
Subversion @ JUG Milano 11 dic 2009 by Andrea Francia
Subversion @ JUG Milano 11 dic 2009Subversion @ JUG Milano 11 dic 2009
Subversion @ JUG Milano 11 dic 2009
Andrea Francia1.3K views
Writing a Crawler with Python and TDD by Andrea Francia
Writing a Crawler with Python and TDDWriting a Crawler with Python and TDD
Writing a Crawler with Python and TDD
Andrea Francia1.9K views

Similar to Working Effectively with Legacy Code (draft)

Best practices unit testing by
Best practices unit testing Best practices unit testing
Best practices unit testing Tricode (part of Dept)
1.2K views20 slides
Shift-Left Testing: QA in a DevOps World by David Laulusa by
Shift-Left Testing: QA in a DevOps World by David LaulusaShift-Left Testing: QA in a DevOps World by David Laulusa
Shift-Left Testing: QA in a DevOps World by David LaulusaQA or the Highway
257 views118 slides
Agile Android by
Agile AndroidAgile Android
Agile AndroidGodfrey Nolan
165 views49 slides
Jason code testing framework by
Jason code testing frameworkJason code testing framework
Jason code testing frameworkCleber Jorge Amaral
34 views24 slides
An introduction to Google test framework by
An introduction to Google test frameworkAn introduction to Google test framework
An introduction to Google test frameworkAbner Chih Yi Huang
9.2K views40 slides
2016 10-04: tdd++: tdd made easier by
2016 10-04: tdd++: tdd made easier2016 10-04: tdd++: tdd made easier
2016 10-04: tdd++: tdd made easierChristian Hujer
394 views111 slides

Similar to Working Effectively with Legacy Code (draft)(20)

Shift-Left Testing: QA in a DevOps World by David Laulusa by QA or the Highway
Shift-Left Testing: QA in a DevOps World by David LaulusaShift-Left Testing: QA in a DevOps World by David Laulusa
Shift-Left Testing: QA in a DevOps World by David Laulusa
QA or the Highway257 views
2016 10-04: tdd++: tdd made easier by Christian Hujer
2016 10-04: tdd++: tdd made easier2016 10-04: tdd++: tdd made easier
2016 10-04: tdd++: tdd made easier
Christian Hujer394 views
Generating characterization tests for legacy code by Jonas Follesø
Generating characterization tests for legacy codeGenerating characterization tests for legacy code
Generating characterization tests for legacy code
Jonas Follesø1.6K views
Effective Unit Test Style Guide by Jacky Lai
Effective Unit Test Style GuideEffective Unit Test Style Guide
Effective Unit Test Style Guide
Jacky Lai672 views
Set operators - derived tables and CTEs by Steve Stedman
Set operators - derived tables and CTEsSet operators - derived tables and CTEs
Set operators - derived tables and CTEs
Steve Stedman1.3K views
Set Operators, Derived Tables and CTEs by Aaron Buma
Set Operators, Derived Tables and CTEsSet Operators, Derived Tables and CTEs
Set Operators, Derived Tables and CTEs
Aaron Buma2.9K views
Programming with GUTs by catherinewall
Programming with GUTsProgramming with GUTs
Programming with GUTs
catherinewall1.8K views
STAMP Descartes Presentation by STAMP Project
STAMP Descartes PresentationSTAMP Descartes Presentation
STAMP Descartes Presentation
STAMP Project105 views
Bad test, good test by Seb Rose
Bad test, good testBad test, good test
Bad test, good test
Seb Rose6.7K views

More from Andrea Francia

Baby Steps TripServiceKata by
Baby Steps TripServiceKataBaby Steps TripServiceKata
Baby Steps TripServiceKataAndrea Francia
389 views39 slides
TDD on Legacy Code - Voxxed Days Milano 2019 by
TDD on Legacy Code - Voxxed Days Milano 2019TDD on Legacy Code - Voxxed Days Milano 2019
TDD on Legacy Code - Voxxed Days Milano 2019Andrea Francia
291 views18 slides
Lavorare con codice legacy “non testabile” - Incontro DevOps - 8 marzo 2019 -... by
Lavorare con codice legacy “non testabile” - Incontro DevOps - 8 marzo 2019 -...Lavorare con codice legacy “non testabile” - Incontro DevOps - 8 marzo 2019 -...
Lavorare con codice legacy “non testabile” - Incontro DevOps - 8 marzo 2019 -...Andrea Francia
506 views24 slides
Kata in Bash a DevOpsHeroes 2018 a Parma by
Kata in Bash a DevOpsHeroes 2018 a ParmaKata in Bash a DevOpsHeroes 2018 a Parma
Kata in Bash a DevOpsHeroes 2018 a ParmaAndrea Francia
150 views6 slides
User Stories - Andrea Francia @ WeDev 7 novembre 2018 by
User Stories - Andrea Francia @ WeDev 7 novembre 2018User Stories - Andrea Francia @ WeDev 7 novembre 2018
User Stories - Andrea Francia @ WeDev 7 novembre 2018Andrea Francia
459 views94 slides
Le pratiche ingegneristiche di eXtreme Programming by
Le pratiche ingegneristiche di eXtreme ProgrammingLe pratiche ingegneristiche di eXtreme Programming
Le pratiche ingegneristiche di eXtreme ProgrammingAndrea Francia
467 views135 slides

More from Andrea Francia(14)

TDD on Legacy Code - Voxxed Days Milano 2019 by Andrea Francia
TDD on Legacy Code - Voxxed Days Milano 2019TDD on Legacy Code - Voxxed Days Milano 2019
TDD on Legacy Code - Voxxed Days Milano 2019
Andrea Francia291 views
Lavorare con codice legacy “non testabile” - Incontro DevOps - 8 marzo 2019 -... by Andrea Francia
Lavorare con codice legacy “non testabile” - Incontro DevOps - 8 marzo 2019 -...Lavorare con codice legacy “non testabile” - Incontro DevOps - 8 marzo 2019 -...
Lavorare con codice legacy “non testabile” - Incontro DevOps - 8 marzo 2019 -...
Andrea Francia506 views
Kata in Bash a DevOpsHeroes 2018 a Parma by Andrea Francia
Kata in Bash a DevOpsHeroes 2018 a ParmaKata in Bash a DevOpsHeroes 2018 a Parma
Kata in Bash a DevOpsHeroes 2018 a Parma
Andrea Francia150 views
User Stories - Andrea Francia @ WeDev 7 novembre 2018 by Andrea Francia
User Stories - Andrea Francia @ WeDev 7 novembre 2018User Stories - Andrea Francia @ WeDev 7 novembre 2018
User Stories - Andrea Francia @ WeDev 7 novembre 2018
Andrea Francia459 views
Le pratiche ingegneristiche di eXtreme Programming by Andrea Francia
Le pratiche ingegneristiche di eXtreme ProgrammingLe pratiche ingegneristiche di eXtreme Programming
Le pratiche ingegneristiche di eXtreme Programming
Andrea Francia467 views
Test-Driven Development su Codice Esistente by Andrea Francia
Test-Driven Development su Codice EsistenteTest-Driven Development su Codice Esistente
Test-Driven Development su Codice Esistente
Andrea Francia107 views
Le 12 pratiche - Un introduzione a XP (Mini Italian Agile Day) by Andrea Francia
Le 12 pratiche - Un introduzione a XP (Mini Italian Agile Day)Le 12 pratiche - Un introduzione a XP (Mini Italian Agile Day)
Le 12 pratiche - Un introduzione a XP (Mini Italian Agile Day)
Andrea Francia799 views
Introduzione a eXtreme Programming by Andrea Francia
Introduzione a eXtreme ProgrammingIntroduzione a eXtreme Programming
Introduzione a eXtreme Programming
Andrea Francia279 views
Test-Driven Development e Sviluppo Incrementale (TDD-Milano 2017-01-10) by Andrea Francia
Test-Driven Development e Sviluppo Incrementale (TDD-Milano 2017-01-10)Test-Driven Development e Sviluppo Incrementale (TDD-Milano 2017-01-10)
Test-Driven Development e Sviluppo Incrementale (TDD-Milano 2017-01-10)
Andrea Francia271 views
Google C++ Testing Framework in Visual Studio 2008 by Andrea Francia
Google C++ Testing Framework in Visual Studio 2008Google C++ Testing Framework in Visual Studio 2008
Google C++ Testing Framework in Visual Studio 2008
Andrea Francia4.8K views

Recently uploaded

The Role of Patterns in the Era of Large Language Models by
The Role of Patterns in the Era of Large Language ModelsThe Role of Patterns in the Era of Large Language Models
The Role of Patterns in the Era of Large Language ModelsYunyao Li
91 views65 slides
"Package management in monorepos", Zoltan Kochan by
"Package management in monorepos", Zoltan Kochan"Package management in monorepos", Zoltan Kochan
"Package management in monorepos", Zoltan KochanFwdays
34 views18 slides
Why and How CloudStack at weSystems - Stephan Bienek - weSystems by
Why and How CloudStack at weSystems - Stephan Bienek - weSystemsWhy and How CloudStack at weSystems - Stephan Bienek - weSystems
Why and How CloudStack at weSystems - Stephan Bienek - weSystemsShapeBlue
247 views13 slides
Cencora Executive Symposium by
Cencora Executive SymposiumCencora Executive Symposium
Cencora Executive Symposiummarketingcommunicati21
160 views14 slides
Future of Indian ConsumerTech by
Future of Indian ConsumerTechFuture of Indian ConsumerTech
Future of Indian ConsumerTechKapil Khandelwal (KK)
36 views68 slides
LLMs in Production: Tooling, Process, and Team Structure by
LLMs in Production: Tooling, Process, and Team StructureLLMs in Production: Tooling, Process, and Team Structure
LLMs in Production: Tooling, Process, and Team StructureAggregage
57 views77 slides

Recently uploaded(20)

The Role of Patterns in the Era of Large Language Models by Yunyao Li
The Role of Patterns in the Era of Large Language ModelsThe Role of Patterns in the Era of Large Language Models
The Role of Patterns in the Era of Large Language Models
Yunyao Li91 views
"Package management in monorepos", Zoltan Kochan by Fwdays
"Package management in monorepos", Zoltan Kochan"Package management in monorepos", Zoltan Kochan
"Package management in monorepos", Zoltan Kochan
Fwdays34 views
Why and How CloudStack at weSystems - Stephan Bienek - weSystems by ShapeBlue
Why and How CloudStack at weSystems - Stephan Bienek - weSystemsWhy and How CloudStack at weSystems - Stephan Bienek - weSystems
Why and How CloudStack at weSystems - Stephan Bienek - weSystems
ShapeBlue247 views
LLMs in Production: Tooling, Process, and Team Structure by Aggregage
LLMs in Production: Tooling, Process, and Team StructureLLMs in Production: Tooling, Process, and Team Structure
LLMs in Production: Tooling, Process, and Team Structure
Aggregage57 views
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlue by ShapeBlue
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlueCloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlue
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlue
ShapeBlue137 views
NTGapps NTG LowCode Platform by Mustafa Kuğu
NTGapps NTG LowCode Platform NTGapps NTG LowCode Platform
NTGapps NTG LowCode Platform
Mustafa Kuğu437 views
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha... by ShapeBlue
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
ShapeBlue183 views
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue by ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlueCloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
ShapeBlue139 views
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ... by ShapeBlue
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
ShapeBlue129 views
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or... by ShapeBlue
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
ShapeBlue199 views
The Power of Heat Decarbonisation Plans in the Built Environment by IES VE
The Power of Heat Decarbonisation Plans in the Built EnvironmentThe Power of Heat Decarbonisation Plans in the Built Environment
The Power of Heat Decarbonisation Plans in the Built Environment
IES VE84 views
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ... by ShapeBlue
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
ShapeBlue120 views
Transcript: Redefining the book supply chain: A glimpse into the future - Tec... by BookNet Canada
Transcript: Redefining the book supply chain: A glimpse into the future - Tec...Transcript: Redefining the book supply chain: A glimpse into the future - Tec...
Transcript: Redefining the book supply chain: A glimpse into the future - Tec...
BookNet Canada41 views
Initiating and Advancing Your Strategic GIS Governance Strategy by Safe Software
Initiating and Advancing Your Strategic GIS Governance StrategyInitiating and Advancing Your Strategic GIS Governance Strategy
Initiating and Advancing Your Strategic GIS Governance Strategy
Safe Software184 views
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P... by ShapeBlue
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
ShapeBlue196 views
Business Analyst Series 2023 - Week 4 Session 8 by DianaGray10
Business Analyst Series 2023 -  Week 4 Session 8Business Analyst Series 2023 -  Week 4 Session 8
Business Analyst Series 2023 - Week 4 Session 8
DianaGray10145 views

Working Effectively with Legacy Code (draft)

  • 1. Working Effectively with Legacy Code written by Michael Feathers Something I understand about the book
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14. Conclusions: Complaints / Solutions matrix So then you ... But legacy code… add them (as characterization tests) lacks of test redesign it (with refactoring) is ugly
  • 15.
  • 16.

Editor's Notes

  1. M